Skip to main content

directory-tree-html

Generate a searchable, single-page HTML directory tree with file previews. Built with Click, Jinja2, Vue 3, and the Element Plus Tree component.

Requires Python 3.10 or later.

Features

  • Expandable folders with distinct file and folder icons.
  • Case-insensitive search across names, paths, file types, extensions, and MIME types.
  • Highlighted matches with automatic expansion of matching paths.
  • Click-to-preview support for text, code, images, PDF, audio, and video.
  • Configurable hidden-file handling, glob exclusions, and preview size limits.
  • Optional symlink traversal with cycle detection.

Installation

python -m pip install directory-tree-html

Quick Start

tree-html-generator ./my-project -o tree.html --title "Project Files"

Open tree.html in your browser to browse the directory snapshot.

You can also run the tool as a Python module:

python -m directory_tree_html ./my-project -o tree.html

Command-Line Options

Option Description Default
DIRECTORY Directory to scan (required) -
-o, --output Output HTML path; parent directories are created automatically directory_tree.html
--title Page title Directory Tree Preview
--include-hidden Include dot-prefixed files and folders Disabled
--follow-symlinks Follow symbolic links with cycle detection Disabled
--exclude GLOB Exclude by name or relative path; repeatable None
--max-preview-bytes Maximum embedded bytes per file; 0 disables previews 262144 (256 KiB)
--version Show the version -
-h, --help Show help -

Examples

# Include hidden files and exclude common generated directories.
tree-html-generator . -o tree.html --include-hidden --exclude .git --exclude __pycache__ --exclude .venv --exclude build --exclude dist

# Exclude file patterns. Quote globs to prevent shell expansion.
tree-html-generator ./my-project -o tree.html --exclude "*.pyc" --exclude "*.tmp"

# Generate the tree without embedding file contents.
tree-html-generator ./my-project -o tree.html --max-preview-bytes 0

Python API

from directory_tree_html import generate_tree_html

result = generate_tree_html(
    "./my-project",
    output="tree.html",
    title="Project Files",
    excludes=["__pycache__", "*.pyc"],
    max_preview_bytes=256 * 1024,
)

print(result.output)           # Absolute output path
print(result.stats)            # Scan statistics
print(result.payload["tree"])  # Serializable tree data

Notes

  • Search uses literal substring matching, ignores case, and trims surrounding whitespace. It searches names and metadata, not file contents. Clearing the search restores the full tree.
  • Vue and Element Plus are loaded from a CDN, so an internet connection is required to open the page. The HTML is not fully offline.
  • Paths and previewable file contents are embedded in the HTML. Review the output before sharing it, or use exclusions and disable previews to avoid exposing sensitive data.
  • Files exceeding the preview limit are not embedded. PDF and media previews depend on browser support.
  • The output is a snapshot; regenerate it after source files change. Generated HTML uses UTF-8 encoding and LF line endings.

Metadata

Release files for directory-tree-html 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for directory-tree-html 0.2.0
File Size Uploaded Provenance Actions
directory_tree_html-0.2.0.tar.gz 18.9 kB Without provenance Details for directory_tree_html-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for directory-tree-html 0.2.0
File Interpreter ABI Platform Actions
directory_tree_html-0.2.0-py3-none-any.whl Python 3 none any Details for directory_tree_html-0.2.0-py3-none-any.whl

Total release size: 34.4 kB

Release files / directory_tree_html-0.2.0.tar.gz

Download URL directory_tree_html-0.2.0.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ff2358f025d2ec60894aef62cb70683af7a485dfcc9d0f20e7f6bce997ba853f
BLAKE2b-256 checksum
How to use checksums
982b1e3603cd6f25a4706f6eadb560c8f3d56633b2bbe4c7b9b707673d4c0dbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / directory_tree_html-0.2.0-py3-none-any.whl

Download URL directory_tree_html-0.2.0-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb71932fe8bd3f6fbcd13558f5423382f2ddeee3a188ed3c0262a8203b9015cf
BLAKE2b-256 checksum
How to use checksums
c0fa307f07c419ef12261c0cc51e1b088504cf31d58bba1007c787d95cf0b9a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for directory-tree-html 0.2.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page