11# TreeMapper
22
3- A tool for converting directory structures to YAML format , designed for use with Large Language Models (LLMs).
4- TreeMapper maps your entire codebase into a structured YAML file, making it easy to analyze code, document projects, and
3+ A tool for converting directory structures to structured formats ( YAML, JSON, or text) , designed for use with Large Language Models (LLMs).
4+ TreeMapper maps your entire codebase into a structured file, making it easy to analyze code, document projects, and
55work with AI tools.
66
77[ ![ Build Status] ( https://img.shields.io/github/actions/workflow/status/nikolay-e/TreeMapper/ci.yml )] ( https://github.com/nikolay-e/TreeMapper/actions )
@@ -18,10 +18,10 @@ pip install treemapper
1818
1919## Usage
2020
21- Generate a YAML tree of a directory:
21+ Generate a structured representation of a directory:
2222
2323``` bash
24- # Map current directory to stdout
24+ # Map current directory to stdout (YAML format)
2525treemapper .
2626
2727# Map specific directory to stdout
@@ -33,11 +33,29 @@ treemapper . -o my-tree.yaml
3333# Use "-" to explicitly output to stdout
3434treemapper . -o -
3535
36+ # Output in JSON format
37+ treemapper . --format json
38+
39+ # Output in plain text format
40+ treemapper . --format text -o output.txt
41+
42+ # Limit directory traversal depth
43+ treemapper . --max-depth 3
44+
45+ # Skip file contents (structure only)
46+ treemapper . --no-content
47+
48+ # Limit file size for content reading
49+ treemapper . --max-file-bytes 10000
50+
3651# Custom ignore patterns
3752treemapper . -i ignore.txt
3853
3954# Disable all default ignores
4055treemapper . --no-default-ignores
56+
57+ # Combine multiple options
58+ treemapper . -o tree.json --format json --max-depth 5 --max-file-bytes 50000
4159```
4260
4361### Options
@@ -49,10 +67,15 @@ Arguments:
4967 DIRECTORY Directory to analyze (default: current directory)
5068
5169Options:
52- -o, --output-file FILE Output YAML file (default: stdout)
70+ -o, --output-file PATH Output file (default: stdout)
5371 Use "-" to force stdout output
54- -i, --ignore-file FILE Custom ignore patterns file
72+ --format {yaml,json,text} Output format (default: yaml)
73+ -i, --ignore-file PATH Custom ignore patterns file
5574 --no-default-ignores Disable all default ignores (.gitignore, .treemapperignore, etc.)
75+ --max-depth N Maximum depth to traverse (default: unlimited)
76+ --no-content Skip reading file contents (structure-only mode)
77+ --max-file-bytes N Maximum file size to read in bytes (default: unlimited)
78+ Larger files will show a placeholder
5679 -v, --verbosity [0-3] Logging verbosity (default: 0)
5780 0=ERROR, 1=WARNING, 2=INFO, 3=DEBUG
5881 --version Show version and exit
@@ -75,6 +98,7 @@ Use `--no-default-ignores` to disable all default ignores and only use patterns
7598
7699### Example Output
77100
101+ ** YAML format (default):**
78102``` yaml
79103name : my-project
80104type : directory
@@ -94,6 +118,52 @@ children:
94118 Documentation here...
95119` ` `
96120
121+ **JSON format (` --format json`):**
122+ ` ` ` json
123+ {
124+ "name": "my-project",
125+ "type": "directory",
126+ "children": [
127+ {
128+ "name": "src",
129+ "type": "directory",
130+ "children": [
131+ {
132+ "name": "main.py",
133+ "type": "file",
134+ "content": "def main():\n print(\" Hello World\" )\n "
135+ }
136+ ]
137+ },
138+ {
139+ "name": "README.md",
140+ "type": "file",
141+ "content": "# My Project\n Documentation here...\n "
142+ }
143+ ]
144+ }
145+ ` ` `
146+
147+ **Text format (`--format text`):**
148+ ```
149+ ================================================================================
150+ Directory Tree: my-project
151+ ================================================================================
152+
153+ src/ (directory)
154+ main.py (file)
155+ --- BEGIN CONTENT ---
156+ def main():
157+ print("Hello World")
158+ --- END CONTENT ---
159+
160+ README.md (file)
161+ --- BEGIN CONTENT ---
162+ # My Project
163+ Documentation here...
164+ --- END CONTENT ---
165+ ```
166+
97167## License
98168
99169Apache License 2.0 - see [LICENSE](LICENSE) for details.
0 commit comments