A tool for mapping directory structures
Project description
TreeMapper
A tool for converting directory structures to structured formats (YAML, JSON, or text), designed for use with Large Language Models (LLMs). TreeMapper maps your entire codebase into a structured file, making it easy to analyze code, document projects, and work with AI tools.
Installation
Requires Python 3.9+:
pip install treemapper
Usage
Generate a structured representation of a directory:
# Map current directory to stdout (YAML format)
treemapper .
# Map specific directory to stdout
treemapper /path/to/dir
# Save to a file
treemapper . -o my-tree.yaml
# Use "-" to explicitly output to stdout
treemapper . -o -
# Output in JSON format
treemapper . --format json
# Output in plain text format
treemapper . --format text -o output.txt
# Limit directory traversal depth
treemapper . --max-depth 3
# Skip file contents (structure only)
treemapper . --no-content
# Limit file size for content reading
treemapper . --max-file-bytes 10000
# Custom ignore patterns
treemapper . -i ignore.txt
# Disable all default ignores
treemapper . --no-default-ignores
# Combine multiple options
treemapper . -o tree.json --format json --max-depth 5 --max-file-bytes 50000
Options
treemapper [OPTIONS] [DIRECTORY]
Arguments:
DIRECTORY Directory to analyze (default: current directory)
Options:
-o, --output-file PATH Output file (default: stdout)
Use "-" to force stdout output
--format {yaml,json,text} Output format (default: yaml)
-i, --ignore-file PATH Custom ignore patterns file
--no-default-ignores Disable all default ignores (.gitignore, .treemapperignore, etc.)
--max-depth N Maximum depth to traverse (default: unlimited)
--no-content Skip reading file contents (structure-only mode)
--max-file-bytes N Maximum file size to read in bytes (default: unlimited)
Larger files will show a placeholder
-v, --verbosity [0-3] Logging verbosity (default: 0)
0=ERROR, 1=WARNING, 2=INFO, 3=DEBUG
--version Show version and exit
-h, --help Show this help
Ignore Patterns
By default, TreeMapper ignores:
- The output file itself (when using
-o) - All
.gitdirectories - Python cache directories (
__pycache__,.pytest_cache,.mypy_cache, etc.) - Python build artifacts (
*.pyc,*.egg-info,dist/,build/, etc.) - Patterns from
.gitignorefiles (in the scanned directory and subdirectories) - Patterns from
.treemapperignorefile (in the scanned root directory) - Symbolic links (always skipped)
Use --no-default-ignores to disable all default ignores and only use patterns from -i/--ignore-file.
Example Output
YAML format (default):
name: my-project
type: directory
children:
- name: src
type: directory
children:
- name: main.py
type: file
content: |
def main():
print("Hello World")
- name: README.md
type: file
content: |
# My Project
Documentation here...
JSON format (--format json):
{
"name": "my-project",
"type": "directory",
"children": [
{
"name": "src",
"type": "directory",
"children": [
{
"name": "main.py",
"type": "file",
"content": "def main():\n print(\"Hello World\")\n"
}
]
},
{
"name": "README.md",
"type": "file",
"content": "# My Project\nDocumentation here...\n"
}
]
}
Text format (--format text):
================================================================================
Directory Tree: my-project
================================================================================
src/ (directory)
main.py (file)
--- BEGIN CONTENT ---
def main():
print("Hello World")
--- END CONTENT ---
README.md (file)
--- BEGIN CONTENT ---
# My Project
Documentation here...
--- END CONTENT ---
License
Apache License 2.0 - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file treemapper-1.1.0.tar.gz.
File metadata
- Download URL: treemapper-1.1.0.tar.gz
- Upload date:
- Size: 36.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41330ab97b0e68553e5da167745bd36f34248e116b82b4fd994e060dee845f44
|
|
| MD5 |
f623c9de08ddbd734ae7151c6a51fd6a
|
|
| BLAKE2b-256 |
0cc4006d6b7ec6067aaa994c1f2e17c8d780476241bb6f0ba6c8e5f590d87681
|
Provenance
The following attestation bundles were made for treemapper-1.1.0.tar.gz:
Publisher:
cd.yml on nikolay-e/TreeMapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
treemapper-1.1.0.tar.gz -
Subject digest:
41330ab97b0e68553e5da167745bd36f34248e116b82b4fd994e060dee845f44 - Sigstore transparency entry: 615332972
- Sigstore integration time:
-
Permalink:
nikolay-e/TreeMapper@701f819412ebdf584a73c9f1ef5b5ef6b9e840ea -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nikolay-e
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@701f819412ebdf584a73c9f1ef5b5ef6b9e840ea -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file treemapper-1.1.0-py3-none-any.whl.
File metadata
- Download URL: treemapper-1.1.0-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c7533eb2a9039068758e1e4caba32e27bbd146890c561caa4181ed4414fdc84
|
|
| MD5 |
0d4dbc5a4a21dc982ec98c36e2c25dd9
|
|
| BLAKE2b-256 |
46d54562cd8926a76cf4b3bf8ec5b75c12ef2a32c4cdec2d619222410b826252
|
Provenance
The following attestation bundles were made for treemapper-1.1.0-py3-none-any.whl:
Publisher:
cd.yml on nikolay-e/TreeMapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
treemapper-1.1.0-py3-none-any.whl -
Subject digest:
4c7533eb2a9039068758e1e4caba32e27bbd146890c561caa4181ed4414fdc84 - Sigstore transparency entry: 615333016
- Sigstore integration time:
-
Permalink:
nikolay-e/TreeMapper@701f819412ebdf584a73c9f1ef5b5ef6b9e840ea -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nikolay-e
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@701f819412ebdf584a73c9f1ef5b5ef6b9e840ea -
Trigger Event:
workflow_dispatch
-
Statement type: