A CLI tool that analyzes directory structures and outputs them as JSON. Built with Bun and TypeScript.
Sometimes you just need a quick way to get a directory's structure as JSON - maybe for documentation, feeding into an LLM, or just understanding a codebase. TreeEx does exactly that, with sensible defaults and cross-platform support.
Requirements:
- Bun
- Git
git clone https://github.com/pratikdev/treeex.git
cd treeex
bun install# Build for current platform
bun run build
# Check [package.json](./package.json) for more optionsThis produces a standalone binary in the build/ directory for your OS
# cd into the build directory
cd build
# Analyze current directory (`/build` directory will be empty though)
treeEx
# Analyze a specific path
treeEx ../src
# Limit depth
treeEx --depth 3
# Unlimited depth
treeEx --depth inf
# Ignore additional patterns
treeEx -i "*.log" -i "*.tmp"
# Include everything (disable default ignores)
treeEx --no-default-ignoreTreeEx outputs a JSON tree structure:
{
"name": "root",
"type": "directory",
"children": [
{
"name": "src",
"type": "directory",
"children": [
{
"name": "index.ts",
"type": "file",
"children": []
}
]
},
{
"name": "package.json",
"type": "file",
"children": []
}
]
}By default, TreeEx ignores common noise directories and files:
.git,.svn,.hg,.CVSnode_modules,vendorbuild,dist,out.vscode,.DS_Store
Use --no-default-ignore to include everything.
| Option | Description |
|---|---|
-d, --depth <level> |
Maximum depth level (default: 20, use "inf" for unlimited) |
-i, --ignore <pattern> |
Glob pattern to ignore (can be used multiple times) |
--no-default-ignore |
Disable default ignore patterns |
-v, --version |
Show version |
-h, --help |
Show help |
MIT