Skip to main content

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.

Build Status PyPI License

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 .git directories
  • Python cache directories (__pycache__, .pytest_cache, .mypy_cache, etc.)
  • Python build artifacts (*.pyc, *.egg-info, dist/, build/, etc.)
  • Patterns from .gitignore files (in the scanned directory and subdirectories)
  • Patterns from .treemapperignore file (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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

treemapper-1.1.0.tar.gz (36.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

treemapper-1.1.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

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

Hashes for treemapper-1.1.0.tar.gz
Algorithm Hash digest
SHA256 41330ab97b0e68553e5da167745bd36f34248e116b82b4fd994e060dee845f44
MD5 f623c9de08ddbd734ae7151c6a51fd6a
BLAKE2b-256 0cc4006d6b7ec6067aaa994c1f2e17c8d780476241bb6f0ba6c8e5f590d87681

See more details on using hashes here.

Provenance

The following attestation bundles were made for treemapper-1.1.0.tar.gz:

Publisher: cd.yml on nikolay-e/TreeMapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for treemapper-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c7533eb2a9039068758e1e4caba32e27bbd146890c561caa4181ed4414fdc84
MD5 0d4dbc5a4a21dc982ec98c36e2c25dd9
BLAKE2b-256 46d54562cd8926a76cf4b3bf8ec5b75c12ef2a32c4cdec2d619222410b826252

See more details on using hashes here.

Provenance

The following attestation bundles were made for treemapper-1.1.0-py3-none-any.whl:

Publisher: cd.yml on nikolay-e/TreeMapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page