folder-tree-print
v1.0.0
Published
Print a beautiful tree view of any folder structure. Great for LLM context, docs, and sharing project layouts.
Maintainers
Readme
folder-tree-print
A zero-dependency CLI tool that prints your folder structure as a beautiful, colorized tree. Great for LLM context, README docs, and sharing project layouts.
What it does
Running folder-tree-print in any directory prints a tree view of its contents:
my-project/
├── src/
│ ├── components/
│ │ ├── Header.tsx
│ │ └── Footer.tsx
│ ├── utils/
│ │ └── helpers.ts
│ └── index.ts
├── package.json
├── tsconfig.json
└── README.md
3 directories, 6 filesIt automatically colorizes output (directories in blue, symlinks in cyan, executables in green), sorts directories before files, and skips common noise like node_modules and .git.
Install
npm install -g folder-tree-printOr run directly with npx:
npx folder-tree-printUsage
# Current directory
folder-tree
# Specific folder
folder-tree-print ./src
# Limit depth
folder-tree-print -L 3
# Include hidden files, ignore specific folders
folder-tree-print -a -I logs -I tmp
# Directories only
folder-tree-print --dirs-only
# JSON output (great for piping)
folder-tree-print --json > structure.json
# Flat list
folder-tree-print --flat
# ASCII mode for legacy terminals
folder-tree-print --ascii
# Combine flags
folder-tree-print ./src -L 2 -d --no-colorConfiguration
The script includes a CONFIG object at the top of the file that you can edit before running. Here's the full reference:
Display Format
| Option | Default | Description |
| --------------- | ---------- | -------------------------------------------------------------------------------- |
| displayFormat | "tree" | "tree" for box-drawing tree, "flat" for flat paths, "json" for JSON output |
| treeStyle | "unicode"| "unicode" for ├── └──, "ascii" for +-- \--` (legacy terminal fallback) |
Sorting
| Option | Default | Description |
| ----------- | -------------- | -------------------------------------------------------------------------------- |
| sortOrder | "dirs-first" | "dirs-first" groups dirs above files, "alpha" pure alphabetical, "none" filesystem order |
Filtering
| Option | Default | Description |
| ------------------- | ------- | ---------------------------------------------------------------- |
| showHidden | false | Show hidden files and directories (dotfiles) |
| dirsOnly | false | Show only directories, hide all files |
| maxDepth | 0 | Maximum depth to traverse (0 = no limit) |
| extraSkipDirs | [] | Additional directories to skip (merged with built-in list) |
| extraSkipFiles | [] | Additional files to skip (merged with built-in list) |
| onlyExtensions | [] | Only show files matching these extensions (empty = all) |
| excludeExtensions | [] | Hide files matching these extensions |
Colors
| Option | Default | Description |
| ---------- | ------- | -------------------------------------------------------------------- |
| colorize | true | Enable colored output (blue dirs, cyan symlinks, green executables) |
Output
| Option | Default | Description |
| ------------- | ------- | ---------------------------------------------------- |
| showSummary | true | Show summary line at the end ("X directories, Y files") |
Example Configurations
Only show TypeScript and JavaScript files:
onlyExtensions: ["ts", "tsx", "js", "jsx"],Use ASCII tree characters for CI logs:
treeStyle: "ascii",
colorize: false,Shallow overview with no files:
dirsOnly: true,
maxDepth: 2,CLI Options
| Flag | Short | Description |
| -------------- | ----- | -------------------------------------------- |
| --help | -h | Show help message |
| --all | -a | Include hidden files (dotfiles) |
| --dirs-only | -d | Show only directories |
| --depth <n> | -L | Limit tree depth |
| --ignore <s> | -I | Ignore matching names (repeatable) |
| --no-color | | Disable colored output |
| --no-summary | | Hide the summary line |
| --flat | | Flat list instead of tree |
| --json | | Output as JSON |
| --ascii | | Use ASCII characters instead of Unicode |
Behavior
- Color-coded — directories (blue), symlinks (cyan with → target), executables (green).
- Smart defaults — auto-skips
node_modules,.git,.next,dist,build,vendor,__pycache__,.idea,.vscode, and more. - Sorted output — directories listed before files, alphabetical within each group.
- Symlink-aware — displays symlink targets with
→arrows. - Plural-correct summary — "1 directory, 1 file" vs "3 directories, 12 files".
- Configurable — edit the
CONFIGobject for persistent preferences, or use CLI flags for one-off runs.
License
MIT
