TreeMark is a lightweight Python CLI tool that generates a clean, readable Markdown (or plain text) representation of your project’s directory structure. Perfect for documentation, code walkthroughs, and feeding structured project info to LLMs.
- 📁 Recursively walks through your folder structure
- 📝 Outputs a Markdown tree that works in GitHub, Notion, etc.
- 🧾 Option to output in plain text instead of Markdown
- 📏 Limit directory depth with
--max-depth - 📦 Show file sizes with
--sizes - 💾 Save output to a file with
--output - 🎯 Supports ignoring files/folders
- 🎯 Supports selecting only certain top-level items
- ✅ No external dependencies, pure Python!
Clone the repository:
git clone https://github.com/avirsaha/treemark.git
cd treemark
pip install .Or install in editable mode (for development):
pip install -e .treemarkThis generates a Markdown tree of the current directory.
| Option | Description |
|---|---|
--root PATH |
Root directory to start from (default: current directory) |
--ignore |
Space-separated list of files/folders to ignore |
--select-only |
Space-separated list of top-level items to include exclusively |
--max-depth N |
Limit how deep the recursion goes (e.g., --max-depth 2) |
--sizes |
Show file sizes in bytes next to each file |
--format FORMAT |
Choose output format: markdown (default) or plain |
--output FILE |
Save the tree output to a specified file |
--version |
Display version info and exit |
-h, --help |
Show help message and exit |
treemark --root myproject --ignore __pycache__ venv .git --max-depth 2 --sizes --output structure.mdOutput (Markdown):
# Project Structure
├── README.md (1.2 KB)
├── requirements.txt (57 B)
└── src/
├── main.py (2.1 KB)
└── utils.py (800 B)
- Project READMEs
- Codebase onboarding docs
- Prompting LLMs with structural context
- Static documentation sites
pytestTests are located in the tests/ directory.
To remove build artifacts before packaging or publishing:
Windows:
Remove-Item -Recurse -Force build, dist, *.egg-infomacOS/Linux:
rm -rf build dist *.egg-info- PermissionError: TreeMark now skips inaccessible directories (e.g.,
System Volume Informationon Windows). - Output formatting issues? Make sure you’re viewing the result in a Markdown-capable viewer like GitHub or VSCode.
We welcome PRs and suggestions!
- Fork the repo
- Create a feature branch
- Make your changes
- Write or update tests
- Submit a pull request 🚀
MIT License © 2025 Aviraj Saha
- Add output to file support
- Add folder depth limit
- Add format options (Markdown vs plain text)
- Show file sizes
- Add color themes (for terminal output)
- Add Git integration (e.g., show tracked/untracked)
- GitHub: @avirsaha
- Issues or feature requests? Submit here
- Email: [email protected]