Skip to content

A simple Python utility that scans your project directory and outputs a clean markdown tree of your folder and file structure, perfect for documentation and feeding into language models.

License

Notifications You must be signed in to change notification settings

avirsaha/treemark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codecov Test Status

TreeMark

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.


🚀 Features

  • 📁 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!

📦 Installation

🛠️ From Source (Recommended)

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 .

📂 Usage

Basic Usage

treemark

This generates a Markdown tree of the current directory.

Options

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

Example

treemark --root myproject --ignore __pycache__ venv .git --max-depth 2 --sizes --output structure.md

Output (Markdown):

# Project Structure

├── README.md (1.2 KB)
├── requirements.txt (57 B)
└── src/
    ├── main.py (2.1 KB)
    └── utils.py (800 B)

✅ Ideal For

  • Project READMEs
  • Codebase onboarding docs
  • Prompting LLMs with structural context
  • Static documentation sites

🧪 Testing

pytest

Tests are located in the tests/ directory.


🧹 Cleanup (Dev Only)

To remove build artifacts before packaging or publishing:

Windows:

Remove-Item -Recurse -Force build, dist, *.egg-info

macOS/Linux:

rm -rf build dist *.egg-info

🐛 Troubleshooting

  • PermissionError: TreeMark now skips inaccessible directories (e.g., System Volume Information on Windows).
  • Output formatting issues? Make sure you’re viewing the result in a Markdown-capable viewer like GitHub or VSCode.

🤝 Contributing

We welcome PRs and suggestions!

  1. Fork the repo
  2. Create a feature branch
  3. Make your changes
  4. Write or update tests
  5. Submit a pull request 🚀

📜 License

MIT License © 2025 Aviraj Saha


🔗 Related Projects

  • tree — Classic CLI directory viewer
  • py-tree — CLI tree views, not markdown-focused

✅ TODOs

  • 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)

📣 Stay in Touch

About

A simple Python utility that scans your project directory and outputs a clean markdown tree of your folder and file structure, perfect for documentation and feeding into language models.

Topics

Resources

License

Stars

Watchers

Forks

Languages