prettify-folder-structure
v1.0.0
Published
A CLI tool for converting between plain text and ASCII tree folder structures
Maintainers
Readme
Prettify Folder Structure
A CLI tool for converting between plain indented text and visual ASCII tree representations of folder structures. Share folder hierarchies with AI agents, create documentation, or simply visualize your project structure in a readable format.
Installation
npm install -g prettify-folder-structureUsage
The tool supports two commands: format (default) and parse.
Format: Convert plain text to ASCII tree (default)
prettify-folder-structure format <path-to-text-file>
# or simply
prettify-folder-structure <path-to-text-file>Convert plain indented text into an ASCII tree with box-drawing characters:
Input:
my-react-app/
src/
components/
Button.tsx # Reusable button component
Header.tsx
Footer.tsx
pages/
Home.tsx # Landing page
About.tsx
App.tsx # Main app component
index.tsx
package.jsonOutput:
my-react-app/
├── src/
│ ├── components/
│ │ ├── Button.tsx # Reusable button component
│ │ ├── Header.tsx
│ │ └── Footer.tsx
│ ├── pages/
│ │ ├── Home.tsx # Landing page
│ │ └── About.tsx
│ ├── App.tsx # Main app component
│ └── index.tsx
└── package.jsonParse: Convert ASCII tree back to plain text
prettify-folder-structure parse <path-to-tree-file>Convert an ASCII tree back to plain indented text:
Input:
my-react-app/
├── src/
│ ├── hooks/ # Custom React hooks
│ │ ├── useAuth.ts
│ │ └── useFetch.ts
│ ├── utils/
│ │ └── helpers.ts # Utility functions
│ └── App.tsx
└── vite.config.tsOutput:
my-react-app/
src/
hooks/ # Custom React hooks
useAuth.ts
useFetch.ts
utils/
helpers.ts # Utility functions
App.tsx
vite.config.tsOptions
Format command:
-o, --output <file>- Write output to file instead of stdout
Parse command:
-i, --indent <width>- Indentation width: 2 or 4 spaces (default: 2)-o, --output <file>- Write output to file instead of stdout
Examples
# Convert plain text to ASCII tree
prettify-folder-structure structure.txt
# Save ASCII tree to file
prettify-folder-structure format structure.txt -o project-tree.txt
# Convert ASCII tree back to plain text with 4-space indentation
prettify-folder-structure parse project-tree.txt -i 4
# Save plain text to file
prettify-folder-structure parse project-tree.txt -o structure.txtInput Format
Plain Text Format
Use indentation (2 or 4 spaces) to show hierarchy:
- Folders end with
/ - Comments use
# - Consistent indentation required (no tabs)
react-app/
src/
App.tsx # Main application
index.tsx
public/
index.html
package.jsonASCII Tree Format
Box-drawing characters show hierarchy:
├──for items with siblings below└──for last items│for vertical lines- Folders end with
/ - Comments use
#
react-app/
├── src/
│ ├── App.tsx # Main application
│ └── index.tsx
├── public/
│ └── index.html
└── package.jsonFeatures
- ✨ Bidirectional conversion: Plain text ↔ ASCII tree
- 📦 Flexible indentation: Auto-detects 2 or 4 space indentation
- 💬 Inline comments: Preserve
#comments in both formats - 🎯 Folder detection: Automatically identifies folders vs files
- 📊 Deep nesting: Handles arbitrarily nested structures
- ⚡ Fast: Built with Bun for instant execution
- 🛡️ Error handling: Clear error messages for invalid input
Development
# Run tests
bun test
# Run directly with Bun
bun index.ts structure.txt
# Run parse command
bun run parse project-tree.txtBuilt with Bun - a fast all-in-one JavaScript runtime.
