A CLI tool to generate beautiful directory tree structures for documentation. Automatically respects .gitignore patterns and supports custom ignore patterns.
Quick Start
npx @pavan-kumar-kn/folder_mapper <source_dir> <output_dir>npm install -g @pavan-kumar-kn/folder_mapperNow you can use folder_mapper from anywhere in your terminal.
folder_mapper <source_path> <output_path> [options]
Arguments
<source_path>- Directory to scan (required)<output_path>- Directory where structure.md will be saved (required)
-i, --ignore <patterns>- Additional patterns to ignore (comma-separated)-h, --help- Show help information-v, --version- Show version number
Basic usage (scan current directory)
folder_mapper . ./outputfolder_mapper ./src ./docsfolder_mapper . ./output --ignore "build,temp,cache"folder_mapper ./src ./docs --ignore "*.log,*.tmp,coverage,dist"folder_mapper . ./output -i "build,temp"The tool generates a structure.md file with the following format:
project-root
├── src
│ ├── cmd
│ │ └── command.ts
│ ├── core
│ │ ├── printer.ts
│ │ ├── scanner.ts
│ │ └── tree.ts
│ └── handlers
│ └── handler.ts
├── utils
│ ├── helper.ts
│ └── ignore.ts
├── .gitignore
├── index.ts
├── package.json
├── README.md
└── tsconfig.json
After scanning, the tool displays helpful statistics:
Scan complete!
Stats:
├─ Total files: 42
├─ Total directories: 15
├─ Output path: ./output/structure.md
└─ Time taken: 0.15s
How It Works
- Reads .gitignore file from the source directory (if exists)
- Merges .gitignore patterns with custom --ignore patterns
- Recursively scans the directory structure
- Filters out ignored files and directories
- Builds a tree structure
- Generates structure.md in the output directory
The tool automatically reads and applies patterns from your .gitignore file:
- node_modules
- dist
- build
- .env
- coverage
- etc.
Add additional patterns using the --ignore flag:
folder_mapper . ./output --ignore "temp,cache,*.log"
Patterns are merged with .gitignore, so you don't need to repeat existing ignore rules.
- Generate directory structure for README files
- Document project architecture
- Create folder maps for onboarding
- Visualize codebase structure
- Export project tree for presentations
- Bun runtime or node runtime (if going with the npm version)
For development setup and docs please refer to the Dev Docs.
Phase 2 starts 1/1/26! Check out our Complete Roadmap for upcoming features:
- GitHub Actions integration for auto-updating structure files
- Multiple output formats (JSON, HTML, plain text)
- VSCode extension & enhanced npm usage
Contributions are welcome! Please feel free to submit issues or pull requests.
MIT
Pavan Kumar KN
This project is actively maintained. Please report any issues or suggestions through the GitHub issue tracker.
⭐ If this tool saved you time documenting your project, please consider starring the repo.
It really helps keep the project alive.