Skip to main content

Rich Tree CLI

Rich Tree CLI provides a beautiful, colorful representation of your directory tree using the rich library. Generate stunning visual directory trees with custom icons, multiple export formats, and intelligent filtering - perfect for documentation, project exploration, and sharing repository structures.

Features

  • Beautiful terminal output with colors and custom icons
  • Multiple export formats: HTML, JSON, Markdown, SVG, TOML, XML, and plain text
  • Smart filtering with built-in gitignore support and custom patterns
  • Rich metadata including file sizes, line counts, and file types
  • VS Code integration with clickable file links in HTML output
  • Fast and lightweight with sensible defaults
  • Highly configurable sorting, depth limits, and display options

Quick Start

Installation

Install the CLI globally so it's available from anywhere:

pip install rich-tree-cli

Or with uv:

uv pip install rich-tree-cli

Basic Usage

Generate a tree for the current directory:

rtree

Limit recursion depth:

rtree --depth 2

Export to multiple formats:

rtree --output-format html json markdown toml --output my_project

Show file metadata:

rtree --metadata all --depth 3

Command Options

rtree [DIRECTORY] [OPTIONS]

Core Options

Flag Short Description
--depth -d Maximum depth of recursion (0 = unlimited)
--output -o Output file path (extension determined by format)
--format -f Export format(s): text, html, json, md, svg, toml, xml
--metadata -m Metadata to display: size, lines, created, modified, all, none
--json-shape JSON output shape: nested (default, tree of dicts) or flat (list of files)

Filtering Options

Flag Short Description
--exclude -e Exclude files/directories matching patterns
--gitignore -g Use .gitignore file (optionally specify path)
--sort -s Sort order: files first or dirs first

Display Options

Flag Short Description
--icons -i Icon style: emoji, glyphs, plain
--no-color Disable colored output
--no-console Suppress terminal output (export only)
--version -v Show version

Configuration File

You can set default options in ~/.config/rich_tree_cli/config.toml. CLI arguments always override config file settings.

[defaults]
depth = 3
metadata = ["size", "modified"]
icons = "emoji"
sort = "files"
no_color = false
no_console = false
format = ["text"]
exclude = ["node_modules", "__pycache__", ".git", "*.pyc"]
gitignore_path = "~.gitignore"

Available Options

Option Type Description
depth int Default max depth (0 = unlimited)
metadata list Default metadata fields: size, lines, created, modified, all
icons string Icon style: emoji, glyphs, plain
sort string Sort order: files, dirs
no_color bool Disable colors by default
no_console bool Suppress console output by default
format list Default output format(s)
json_shape string JSON output shape: nested or flat (default: nested)

Exclude patterns in [exclude].patterns are merged with any --exclude flags you provide.

Export Formats

HTML Export

Creates a beautiful web page with VS Code integration:

  • Clickable file links that open in VS Code
  • Custom CSS styling with terminal aesthetics
  • Professional presentation ready for documentation

Markdown Export

Perfect for README files and documentation:

  • Clean, readable format
  • Integrates seamlessly with GitHub/GitLab
  • Great for project overviews

JSON/TOML Export

Machine-readable formats for automation:

  • Complete directory structure data
  • File metadata included
  • Easy integration with other tools
  • TOML output uses [metadata] and [tree] tables mirroring the JSON structure

JSON Shapes

JSON exports come in two shapes, selected with --json-shape:

nested (default) — hierarchical tree of dictionaries, one node per directory:

{
  "metadata": {"total_dirs": 8, "total_files": 22, "root_path": "..."},
  "tree": {
    "src/": {
      "app.py": {"size": 2062, "lines": 56}
    }
  }
}

flat — one record per file, directory structure implicit in the path:

{
  "metadata": {
    "schema_version": 1,
    "root": "...",
    "total_files": 22,
    "total_dirs": 8
  },
  "files": [
    {"path": "src/app.py", "size": 2062, "lines": 56}
  ]
}

The flat shape is friendlier for downstream tooling (grep, jq '.files[]', spreadsheets, data pipelines). Paths are POSIX-normalized and relative to the walked root; entries are sorted by path so identical trees produce identical output (no timestamps in the payload).

XML Export

Structured data for XML pipelines:

  • Human and machine readable
  • Works well with XSLT and other tooling

SVG Export

Vector graphics for presentations and documentation:

  • Scalable visual representation
  • Embeddable in web pages and documents
  • High-quality output for any size

Examples

Documentation Generation

# Generate project overview for README
rtree --format md --output project-structure --depth 3

# Create interactive HTML documentation
rtree --format html --metadata all --output docs/structure

Development Workflows

# Quick project exploration
rtree --depth 2 --icons emoji

# Share repository structure with team
rtree --format html json --output project-overview --exclude "*.pyc" "__pycache__"

# Generate structure for AI assistance
rtree --format text --metadata size --depth 4

# Show size and modification dates
rtree --metadata size modified --depth 3

# Flat JSON for downstream tooling (grep-friendly, jq-friendly)
rtree --format json --json-shape flat --output audit
jq '.files | sort_by(.lines) | reverse | .[0:10]' audit.json  # 10 biggest files by line count

Advanced Filtering

# Exclude build artifacts and dependencies
rtree --exclude "node_modules" "dist" "build" "*.log"

# Use custom gitignore
rtree --gitignore .gitignore-custom --depth 5

# Show only directories
rtree --sort dirs

Why Rich Tree CLI?

  • Developer-focused: Built by developers, for developers, with real workflow needs in mind
  • Beautiful output: No more ugly ASCII trees - get professional, presentation-ready visualizations
  • Flexible exports: One command, multiple formats - perfect for documentation, sharing, and automation
  • Smart defaults: Works great out of the box with sensible gitignore patterns and file detection
  • VS Code integration: Seamlessly integrates with your development environment

Built With

  • Rich - Beautiful terminal output and formatting
  • Jinja2 - Powerful HTML template generation
  • pathspec - Gitignore pattern matching

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rich_tree_cli-0.5.4-py3-none-any.whl (57.4 kB view details)

Uploaded Python 3

File details

Details for the file rich_tree_cli-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: rich_tree_cli-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 57.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rich_tree_cli-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b3069fa518ff93d30ccbcfa1421d44258243d78a38c4046866fc42454e5b732e
MD5 ae111ee46b0a55b16e5db46ba377bd1f
BLAKE2b-256 0f1e8b05e94a2ef493b3d77d4e70df36fa6bff4112d27f23954f042f70b2926a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rich_tree_cli-0.5.4-py3-none-any.whl:

Publisher: build-wheels.yml on sicksubroutine/rich-tree-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.5.5

1 file

This release

0.5.4 This release

1 file

0.5.3

1 file

0.5.0

1 file

0.4.2

1 file

0.4.1

1 file

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