| Crates.io | tree2md |
| lib.rs | tree2md |
| version | 0.8.2 |
| created_at | 2025-08-16 20:55:20.030232+00 |
| updated_at | 2025-09-03 19:32:19.201809+00 |
| description | Like the tree command, but outputs in Markdown. Optionally embed file contents as code blocks. |
| homepage | https://github.com/zawakin/tree2md |
| repository | https://github.com/zawakin/tree2md |
| max_upload_size | |
| id | 1798880 |
| size | 938,994 |
๐ Generate beautiful tree structures in Markdown, HTML, or Terminal format
tree2md # Pretty terminal tree with colors & bars
tree2md --github https://github.com/you/repo --inject README.md # Auto-update your docs with one command!
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.

.env, secrets, node_modules/, .git/ and more--preset readme for docs, --preset fun for emojis & animationscargo install tree2md
# Your Git Repository
tree2md
git clone https://github.com/zawakin/tree2md
cd tree2md
cargo install --path .
Download from GitHub Releases
# Beautiful terminal tree with progress bars and file sizes
tree2md # Auto-detects terminal for colorful output!
tree2md --preset fun # With emojis and animations ๐
# Save as Markdown with full statistics
tree2md --preset readme > STRUCTURE.md
# Auto-inject into README with GitHub links
tree2md --github https://github.com/you/repo/tree/main --inject README.md
# HTML output with collapsible folders
tree2md --output html --fold auto > tree.html
# Focus on specific files (e.g., only Rust files, max 3 levels)
tree2md src/ -L 3 -I "*.rs" --stats full
- src/
- [cli.rs](src/cli.rs) (452 lines)
- [main.rs](src/main.rs) (262 lines)
- tests/
- [emoji_test.rs](tests/emoji_test.rs) (175 lines)
- [filtering_test.rs](tests/filtering_test.rs) (295 lines)
- [safety_test.rs](tests/safety_test.rs) (357 lines)
- [Cargo.toml](Cargo.toml) (36 lines)
- [LICENSE](LICENSE) (21 lines)
- [README.md](README.md) (310 lines)
**Totals**: ๐ 2 dirs โข ๐ 8 files โข ๐งพ ~1.7K LOC
**By type**:
- Test: 3 (38%) ######---------
- Rust: 2 (25%) ####-----------
- Markdown: 1 (13%) ##-------------
- TOML: 1 (13%) ##-------------
- License: 1 (13%) ##-------------
-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 {on|off} โ Toggle Markdown links--github <URL> โ Rewrite links to GitHub--fold {auto|on|off} โ Collapsible folders--no-stats โ Hide stats footer--safe (default) โ Excludes sensitive files--unsafe โ Disable all safety filters--restrict-root <DIR> โ Prevent traversal outside root--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--stamp {version|date|commit|none} โ Add generation metadata--stamp-date-format <FMT> โ Date formatExcluded by default:
.env, .ssh/**, *.pem, *.keynode_modules/, target/, dist/, build/.git/**, .DS_Store, Thumbs.dbUse -I to selectively include, or --unsafe to disable filters.
README injection
tree2md . --github https://github.com/you/repo/tree/main --inject README.md
Docs / Architecture
tree2md src --fold on > docs/ARCHITECTURE.md
Code reviews
tree2md . -L 3 -I "*.rs" -I "*.toml" --no-stats
CI/CD auto-update
tree2md . --github $GITHUB_URL --inject README.md --stamp version
git add README.md
git commit -m "Update structure"
.gitignoregit clone https://github.com/zawakin/tree2md
cd tree2md
cargo build --release
cargo test
PRs welcome! See CONTRIBUTING.md.
For development:
cargo fmt
cargo clippy -- -D warnings
tree2md -L 2 . --output md --inject README.md --tag-start '<tag-start>' --tag-end '<tag-end>'
<!-- tree2md-md:start -->
- .claude/
- .github/
- scripts/
- [update-readme-embeds.sh](scripts/update-readme-embeds.sh) (28 lines)
- src/
- [cli.rs](src/cli.rs) (452 lines)
- [main.rs](src/main.rs) (262 lines)
- tests/
- [emoji_test.rs](tests/emoji_test.rs) (175 lines)
- [exclude_pattern_test.rs](tests/exclude_pattern_test.rs) (125 lines)
- [filtering_test.rs](tests/filtering_test.rs) (295 lines)
- [fixtures.rs](tests/fixtures.rs) (272 lines)
- [html_output_test.rs](tests/html_output_test.rs) (448 lines)
- [include_directory_test.rs](tests/include_directory_test.rs) (112 lines)
- [include_pattern_test.rs](tests/include_pattern_test.rs) (85 lines)
- [links_test.rs](tests/links_test.rs) (377 lines)
- [output_format_test.rs](tests/output_format_test.rs) (177 lines)
- [preset_test.rs](tests/preset_test.rs) (203 lines)
- [safety_test.rs](tests/safety_test.rs) (357 lines)
- [spec_compliance_test.rs](tests/spec_compliance_test.rs) (422 lines)
- [stats_test.rs](tests/stats_test.rs) (279 lines)
- [.gitignore](.gitignore) (30 lines)
- [CHANGELOG.md](CHANGELOG.md) (252 lines)
- [CLAUDE.md](CLAUDE.md) (9 lines)
- [Cargo.lock](Cargo.lock)
- [Cargo.toml](Cargo.toml) (36 lines)
- [LICENSE](LICENSE) (21 lines)
- [README.md](README.md) (310 lines)
**Totals**: ๐ 6 dirs โข ๐ 23 files โข ๐งพ ~4.7K LOC
**By type**:
- Test: 12 (52%) ########-------
- Rust: 3 (13%) ##-------------
- Markdown: 3 (13%) ##-------------
- License: 1 (4%) #--------------
- TOML: 1 (4%) #--------------
- Shell: 1 (4%) #--------------
- Ignore: 1 (4%) #--------------
- Lock: 1 (4%) #--------------
<!-- tree2md-md:end -->
tree2md -L 2 . --output tty --inject README.md --tag-start '<tag-start>' --tag-end '<tag-end>'
<!-- 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 -->
MIT License โ see LICENSE.
Inspired by the classic tree command, designed for Markdown & GitHub integration.
Made with โค๏ธ for the open source community.