tree2md-0.8.2 is not a library.
tree2md
๐ Generate beautiful tree structures in Markdown, HTML, or Terminal format
Transform your project structure into stunning visualizations โ from colorful terminal trees with progress bars to GitHub-ready documentation with clickable links. Perfect for READMEs, architecture docs, and code reviews.

๐ฏ Key Features
- ๐จ Multiple Output Formats โ Markdown, HTML with collapsible folders, or Terminal tree
- ๐ GitHub Integration โ Automatic link rewriting for clickable GitHub navigation
- ๐ Safe by Default โ Auto-excludes
.env, secrets,node_modules/,.git/and more - ๐ Rich Statistics โ File counts, extensions breakdown, lines of code with visual bars
- ๐ README Injection โ Update README.md between tags automatically (idempotent)
- โก Smart Presets โ
--preset readmefor docs,--preset funfor emojis & animations
๐ฅ Installation
From crates.io
# Your Git Repository
From source
Pre-built binaries
Download from GitHub Releases
๐ Quick Start
# Beautiful terminal tree with progress bars and file sizes
# Save as Markdown with full statistics
# Auto-inject into README with GitHub links
# HTML output with collapsible folders
# Focus on specific files (e.g., only Rust files, max 3 levels)
๐ Example Output
- - -- - - ----
**Totals**: ๐ 2 dirs โข ๐ 8 files โข ๐งพ ~1.7K LOC
**By type**:
- ----
๐ ๏ธ CLI Options
Filtering
-L, --level <N>โ Limit traversal depth-I, --include <GLOB>โ Include patterns (repeatable)-X, --exclude <GLOB>โ Exclude patterns (repeatable)--use-gitignore {auto|never|always}โ Respect.gitignore
Links & Output
--links {on|off}โ Toggle Markdown links--github <URL>โ Rewrite links to GitHub--fold {auto|on|off}โ Collapsible folders--no-statsโ Hide stats footer
Safety
--safe(default) โ Excludes sensitive files--unsafeโ Disable all safety filters--restrict-root <DIR>โ Prevent traversal outside root
README Integration
--inject <FILE>โ Update README.md between tags--tag-start <STR>โ Custom start tag (default:<\!-- tree2md:start -->)--tag-end <STR>โ Custom end tag (default:<\!-- tree2md:end -->)--dry-runโ Preview without writing
Metadata
--stamp {version|date|commit|none}โ Add generation metadata--stamp-date-format <FMT>โ Date format
๐ Safety Defaults
Excluded by default:
.env,.ssh/**,*.pem,*.keynode_modules/,target/,dist/,build/.git/**,.DS_Store,Thumbs.db
Use -I to selectively include, or --unsafe to disable filters.
๐ Common Use Cases
README injection
Docs / Architecture
Code reviews
CI/CD auto-update
โก Performance
- Fast โ Parallel traversal with efficient filtering
- Memory safe โ Streams output, no huge buffers
- Deterministic โ Always the same result for same input
- Git-aware โ Respects
.gitignore
๐๏ธ Build from Source
๐ค Contributing
PRs welcome! See CONTRIBUTING.md.
For development:
๐ Project Structure
Markdown-Style
- -- -- - -- - - - - - - - - - - - - --------
**Totals**: ๐ 6 dirs โข ๐ 23 files โข ๐งพ ~4.7K LOC
**By type**:
- -------
Tree(tty)-Style
<!-- tree2md-tree:start -->
|-- .claude/
|-- .github/
|-- scripts/
| `-- update-readme-embeds.sh [โโโโโโโโโโ] 28 (S)
|-- src/
| |-- cli.rs [โโโโโโโโโโ] 452 (L) โ
| `-- main.rs [โโโโโโยทยทยทยท] 262 (M)
|-- tests/
| |-- emoji_test.rs [โโโโยทยทยทยทยทยท] 175 (M)
| |-- exclude_pattern_test.rs [โโโยทยทยทยทยทยทยท] 125 (M)
| |-- filtering_test.rs [โโโโโโโยทยทยท] 295 (M)
| |-- fixtures.rs [โโโโโโโยทยทยท] 272 (M)
| |-- html_output_test.rs [โโโโโโโโโโ] 448 (L) โ
| |-- include_directory_test.rs [โโโยทยทยทยทยทยทยท] 112 (S)
| |-- include_pattern_test.rs [โโยทยทยทยทยทยทยทยท] 85 (S)
| |-- links_test.rs [โโโโโโโโโยท] 377 (L)
| |-- output_format_test.rs [โโโโยทยทยทยทยทยท] 177 (M)
| |-- preset_test.rs [โโโโโยทยทยทยทยท] 203 (M)
| |-- safety_test.rs [โโโโโโโโยทยท] 357 (L)
| |-- spec_compliance_test.rs [โโโโโโโโโโ] 422 (L)
| `-- stats_test.rs [โโโโโโโยทยทยท] 279 (M)
|-- .gitignore [โยทยทยทยทยทยทยทยทยท] 30 (S)
|-- CHANGELOG.md [โโโโโโโโโยท] 252 (M)
|-- CLAUDE.md [ยทยทยทยทยทยทยทยทยทยท] 9 (XS)
|-- Cargo.lock
|-- Cargo.toml [โโยทยทยทยทยทยทยทยท] 36 (S)
|-- LICENSE [โยทยทยทยทยทยทยทยทยท] 21 (S)
`-- README.md [โโโโโโโโโโ] 310 (L)
**Totals**: ๐ 6 dirs โข ๐ 23 files โข ๐งพ ~4.7K LOC
**By type**:
- Test: 12 (52%) ########-------
- Rust: 3 (13%) ##-------------
- Markdown: 3 (13%) ##-------------
- Lock: 1 (4%) #--------------
- Shell: 1 (4%) #--------------
- TOML: 1 (4%) #--------------
- Ignore: 1 (4%) #--------------
- License: 1 (4%) #--------------
<!-- tree2md-tree:end -->
๐ License
MIT License โ see LICENSE.
๐ Acknowledgments
Inspired by the classic tree command, designed for Markdown & GitHub integration.
Made with โค๏ธ for the open source community.