treetable
Helper to pretty print an ascii table with a tree-like structure
What it is and what it does
treetable is a utility for rendering hierarchical data as formatted ASCII tables suitable for terminal output. It takes nested dictionaries and a tree-like schema definition to produce multi-level column headers with customizable separators, alignment, text wrapping, and ANSI color support. The schema is built from `table`, `group`, and `leaf` node functions that define the structure, display names, and formatting rules (alignment, number formats, column shortening) for each column or column group.
The package is useful when you need to display complex, multi-dimensional data in a human-readable tabular format—for instance, experiment results with grouped metrics, hierarchical data exports, or formatted reports in CLI applications. It handles the layout and alignment logic automatically, letting you focus on the data structure and presentation preferences rather than manual spacing and formatting.
Use it for:
- Display machine learning experiment results with grouped train/test metrics and per-model statistics.
- Format hierarchical data exports (e.g., nested JSON or tree-structured database queries) as readable terminal tables.
- Generate formatted CLI reports with multi-level column headers and custom alignment for different data types.
- Pretty-print nested configuration or inventory data with automatic column width and alignment management.
- Create colored terminal output for monitoring dashboards or log analysis tools with grouped metrics.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Renders nested data structures as formatted ASCII tables with hierarchical column grouping and customizable alignment, wrapping, and ANSI color support.
Yes, if you need to render hierarchical tabular data in the terminal. The package is lightweight, dependency-free, and permissively licensed. The aging maintenance status (346 days since last release) is a minor concern for a stable utility, but the lack of active development means no recent bug fixes or feature additions—suitable for stable use cases, less so if you anticipate needing ongoing support.
Install
treetable on PyPI
pip
pip install treetableuv
uv add treetablepoetry
poetry add treetableInstalling treetable
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is aging—last release was 346 days ago, though the repository remains active and the package supports current Python versions.
License in practice
Distributed under the Unlicense, a permissive public-domain dedication. You may use, modify, and distribute the package with no restrictions or attribution requirements.
Quickstart
pip install treetable
from treetable import table, group, leaf, treetable
mytable = table([
group('info', [leaf('name'), leaf('index')]),
group('metrics', [leaf('speed', '.0f'), leaf('accuracy', '.1%')])
])
lines = [
{'info': {'name': 'bob', 'index': 4}, 'metrics': {'speed': 200, 'accuracy': 0.21}},
{'info': {'name': 'alice', 'index': 2}, 'metrics': {'speed': 67, 'accuracy': 0.45}}
]
print(treetable(lines, mytable))
Requires Python 3.6 or later.
Verify before relying
- Whether the package handles deeply nested hierarchies (beyond 3 levels) without performance degradation.
- How the package behaves with very large datasets or extremely wide tables.
- Whether ANSI color codes work correctly on all terminal emulators and Windows console environments.
Package facts
| License | Unlicense license (permissive) |
| Python support | supports the current Python release (>=3.6.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 346 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 311,282/month — #7,737 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: treetable-0.2.6-py3-none-any.whl
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
texttableCreates formatted ASCII tables for console…
permissive · top 1,000 on PyPI
treelibProvides a simple tree data structure…
permissive · top 5,000 on PyPI
tabulateFormats and prints tabular data in plain text…
permissive · top 1,000 on PyPI
seedirGenerates ASCII tree diagrams of folder…
permissive · top 15,000 on PyPI
rst2ansiConverts reStructuredText documents to…
permissive · top 15,000 on PyPI
PTablePTable formats tabular data into visually…
permissive · top 15,000 on PyPI
ansiwrapWraps and formats text while correctly handling…
permissive · top 5,000 on PyPI
asciichartpyRenders line charts as ASCII art in the console…
permissive · top 15,000 on PyPI
ansi2txtConverts ANSI escape sequences (color codes,…
unclear · top 15,000 on PyPI
great-tablesGreat Tables transforms Pandas or Polars…
permissive · top 15,000 on PyPI