🌳 CodeTree
See your codebase as a living, animated tree.
Folders grow into branches, files bloom as leaves — sized by lines of code, colored by language.
Why CodeTree?
Line counters give you a table. CodeTree gives you a map: you instantly see which folders are heavy, which files dominate, and how comments, blank lines and code are balanced — and you can explore it by clicking, zooming and searching.
- 🌱 A tree, not a table — an animated radial tree that grows from the trunk outward.
- 🎨 Language-aware — 40+ languages detected, every line classified as code, comment or blank.
- ⚡ Fast — scans thousands of files in a couple of seconds, in the background, with a live progress view.
- 🧰 Zero dependencies — pure Python standard library (Tkinter for the GUI).
- 🖥️ GUI by default, terminal when you need it — scriptable with JSON / CSV / Markdown export.
Installation
pip install codetree-cli
From source:
git clone https://github.com/rezamardani01/codetree.git
cd codetree
pip install .
Requires Python 3.8+. The GUI uses Tkinter, which ships with the official Python installers (on some Linux distributions install it with e.g.
sudo apt install python3-tk).
Usage
codetree # open the GUI on the current folder
codetree path/to/project # open the GUI on a specific folder
codetree-gui # same, without a console window on Windows
In the window
| Action | What it does |
|---|---|
| Click a folder | Grow or fold its branch (animated) |
| Drag / mouse wheel | Pan / zoom |
| Hover a node | Highlights its path to the trunk and shows lines, code/comment/blank split, size and share of the project |
| Double-click a file | Opens it in your default editor |
| Right-click | Open, show in folder, copy path |
| Search box | Prunes the tree to matching files and folders |
| Click a language | Lights up all leaves written in it |
| Click a file in "Largest files" | Flies the camera to that leaf |
| Expand all · Collapse · Fit view | Overview controls |
| Theme · Export | Dark/light theme, export JSON / CSV / Markdown / standalone HTML |
Shortcuts: F5 rescan · Ctrl+O browse · Ctrl+F search · Ctrl+E export JSON · Esc clear search.
Reading the tree
- Trunk (center) = the project root.
- Branches / green nodes = folders. Thicker branch = more lines. The number on a folded node is how many items it hides.
- Leaves = files, arranged in a sunflower pattern at the end of their branch. Bigger leaf = more lines. Color = language.
Terminal mode
codetree --cli # tree + language table + summary
codetree --cli --depth 2 --sort lines # limit depth, biggest first
codetree --cli --top 10 # also list the 10 largest files
codetree -e py -e js -i "*.min.js" # only these extensions, ignore a pattern
codetree --json report.json # write reports (use - for stdout)
codetree --csv report.csv --md report.md
codetree --html report.html # standalone interactive HTML report
| Option | Description |
|---|---|
--cli |
Print to the terminal instead of opening the GUI |
--json / --csv / --md FILE |
Export a report (implies --cli) |
--html FILE |
Export a standalone interactive HTML report — summary cards, language donut, searchable collapsible tree. Single file, zero dependencies, opens in any browser, great for sharing or CI artifacts (implies --cli) |
-i, --ignore PATTERN |
Glob to ignore, repeatable |
-e, --ext EXT |
Only count these extensions, repeatable |
--hidden |
Include hidden files and folders |
--no-gitignore |
Do not read .gitignore |
--no-default-ignores |
Do not skip node_modules, venv, build, … |
--max-size MB |
Skip files larger than this (default 5) |
--sort name|lines|code, --depth N, --top N |
Terminal tree options |
--no-color |
Disable colors |
-V, --version |
Show the version |
If the GUI cannot start (for example over SSH without a display), CodeTree automatically falls back to terminal output.
Use it as a library
from codetree.core import scan, ScanOptions
result = scan(".", ScanOptions(extensions=["py"], ignore=["tests"]))
print(result.total_files, result.total_lines)
for lang in result.languages.values():
print(lang.name, lang.code, lang.comment, lang.blank)
What gets counted
- Hidden files and folders are skipped (enable with
--hidden/ the Hidden files checkbox). node_modules,venv,__pycache__,dist,build,.git, lock files and similar noise are skipped by default.- Patterns in
.gitignorefiles — in the project root and in subfolders — are respected, including!negations. - Binary files and files over 5 MB are skipped; everything else is read as UTF‑8 with a lenient fallback.
Development
git clone https://github.com/rezamardani01/codetree.git
cd codetree
python -m unittest discover -s tests -t .
python -m codetree . # run from source
Project layout:
codetree/
├── core.py # scanner, language table, line classification, exporters
├── cli.py # command line interface
├── gui.py # animated Tkinter tree
└── tests/
Contributing
Contributions are welcome! Fork the repository, create a branch, add tests for your change and open a pull request. Ideas, bug reports and new language definitions are all appreciated — please open an issue first for larger changes.
License
Released under the MIT License © Reza Mardani.
Metadata
Release files for codetree-cli 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| codetree_cli-0.4.0.tar.gz | 37.3 kB | With provenance | Details for codetree_cli-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| codetree_cli-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for codetree_cli-0.4.0-py3-none-any.whl |
Total release size: 71.7 kB
Release files / codetree_cli-0.4.0.tar.gz
| Download URL | codetree_cli-0.4.0.tar.gz |
|---|---|
| Size | 37.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47e0c9729fcb6484ff4851130182fd9d6746da9d729dd090841510368ac4a700
|
|
BLAKE2b-256 checksum How to use checksums |
b4ad978cce322cec9086709914e6a1aa5f4353e3d4819c7cdb0998d38f63e30f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / codetree_cli-0.4.0-py3-none-any.whl
| Download URL | codetree_cli-0.4.0-py3-none-any.whl |
|---|---|
| Size | 34.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f9804a55c555f082940f4a7f9a58b31cdb8fe76e233c1008bc4f119ba6f75c11
|
|
BLAKE2b-256 checksum How to use checksums |
e7c45f2f877df9e014e95bdc7c79ad76efee0cba0ee4f317b8d9a384b12ca280
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for codetree-cli 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for codetree_cli-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.