Skip to main content

logo nutree

Latest Version Tests codecov License Documentation Status Downloads

Nutree lets you organize and query arbitrary Python objects as a tree — with clones, diffing, and graph export built in.

Trees and nodes behave like familiar Python containers wherever that makes sense — len(tree) counts nodes, for node in tree: ... walks the tree depth-first, and value in tree tests membership. Lookup (tree[value]) matches by id or by the wrapped data (not by position, since a tree has no natural order).

[!TIP] Take the Tour and Read the Docs for more.

Nutree Facts

Handle multiple references of single objects ('clones')
Search by name pattern, id, or object reference
Compare two trees and calculate patches
Unobtrusive handling of arbitrary objects
Save as DOT file and graphwiz diagram
Nodes can be plain strings or objects
(De)Serialize to (compressed) JSON
Save as Mermaid flow diagram
Multiple traversal methods
Generate random trees
Convert to RDF graph
Fully type annotated
Typed child nodes
Memory efficient
Pretty print
Navigation
Filtering
Fast

Example

A simple tree, with text nodes

from nutree import Tree, Node

tree = Tree("Store")

n = tree.add("Records")

n.add("Let It Be")
n.add("Get Yer Ya-Ya's Out!")

n = tree.add("Books")
n.add("The Little Prince")

tree.print()
Tree<'Store'>
├─── 'Records'
│    ├─── 'Let It Be'
│    ╰─── "Get Yer Ya-Ya's Out!"
╰─── 'Books'
     ╰─── 'The Little Prince'

Tree nodes wrap the data and also expose methods for navigation, searching, iteration, ...

records_node = tree["Records"]
assert isinstance(records_node, Node)
assert records_node.name == "Records"

print(records_node.first_child())
Node<'Let It Be', data_id=510268653885439170>

Nodes can holdarbitrary objects (not just strings):

alice = Person("Alice", age=23, guid="{123-456}")
tree.add(alice)

# Lookup nodes by object, data_id, name pattern, ...
alice_node = tree[alice]
assert isinstance(alice_node.data, Person)

del tree[alice]

Take the Tour and Read the Docs for more.

Metadata

Release files for nutree 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nutree 1.2.0
File Size Uploaded
nutree-1.2.0.tar.gz 78.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nutree 1.2.0
File Interpreter ABI Platform
nutree-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 136.1 kB

Release files / nutree-1.2.0.tar.gz

Download URL nutree-1.2.0.tar.gz
Size 78.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f2e505e002df01eeb6a06aca483a70aaa341adc62ab3ebddfabd50a15421edeb
BLAKE2b-256 checksum
How to use checksums
21ff019829f01b17f4c39ebc53f069890aeb8145fd86b08e09ab89110b05465d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release files / nutree-1.2.0-py3-none-any.whl

Download URL nutree-1.2.0-py3-none-any.whl
Size 57.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e44f932b657a213844df3b47f091c67dee92db70845c01e503a387a5b01aad1
BLAKE2b-256 checksum
How to use checksums
dce422ef7b69b9849e9b2b6d36a830cfcedefa7670129de0b01db38be32bcca4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page