ASCII Tree Generator

0.3.3 · maintenance · verified Sun Apr 12

asciitree is a Python library that enables the drawing of tree structures using ASCII characters directly in the terminal. It is currently at version 0.3.3, with its last release in 2016, suggesting a maintenance or inactive release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a hierarchical dictionary structure, using `OrderedDict` for predictable child ordering, and then render it into an ASCII tree using the `LeftAligned` renderer.

from asciitree import LeftAligned
from collections import OrderedDict as OD

tree_data = {
    'root': OD([
        ('child1', {
            'grandchild1_1': {},
            'grandchild1_2': {'subgrandchild': {}}
        }),
        ('child2', {
            'grandchild2_1': {},
        }),
        ('child3', {})
    ])
}

tr = LeftAligned()
print(tr(tree_data))

view raw JSON →