tree2folder
v1.0.8
Published
Generate a directory structure from a text tree diagram
Maintainers
Readme
tree2folder
Create files and folders from a simple ASCII tree diagram.
Demo
Watch how easy it is to create folder structures from ASCII diagrams using tree2folder!

Usage
You can use tree2folder in two ways:
Using npx (no installation required)
To run tree2folder without installing:
npx tree2folder <file-name> [<directory>]<file-name>: Path to the text file containing the directory tree diagram.[<directory>]: (Optional) Target directory where the structure will be created. Defaults to the current working directory.
Global Installation
Install globally using npm:
npm install -g tree2folderAfter installation, you can use it directly:
tree2folder <file-name> [<directory>]Examples
- Basic example (create structure in current directory)
Create diagram.txt with this content:
project
├─ bin/
│ └─ start.sh
├─ src/
│ ├─ index.js
│ └─ helpers.js
└─ README.mdOr
project
bin/
start.sh
src/
index.js
helpers.js
README.mdThen run:
npx tree2folder diagram.txtResult: a project folder containing the described files and folders.
- Create into a specific directory
npx tree2folder diagram.txt ./output-folderThis creates the tree inside ./output-folder (it will be created if it doesn't exist).
Supported input
✅ ASCII-tree structure:
project
├─ bin/
│ └─ start.sh
├─ src/
│ ├─ index.js
│ └─ helpers.js
└─ README.md✅ Indentation-based structure:
project
bin/
start.sh
src/
index.js
helpers.js
README.mdBehavior & tips
- Lines ending with
/are treated as directories. Indentation (spaces) defines nesting. - Tree characters like
├─,└─, and│are ignored, so you can paste output fromtreeor similar utilities and it will still work. - Files are created empty by default. If a path already exists, behavior depends on the CLI implementation (it may skip, warn, or overwrite). Test in a temporary folder if you are unsure.
Contributing
Contributions that improve examples, parser robustness, and helpful CLI flags are welcome.
Small ways to contribute:
- Add examples that show edge cases (spaces in names, many indent levels).
- Add a
--dry-runflag to preview what will be created without making changes. - Add
--forceto overwrite existing files and a--yesflag to skip prompts. - Improve the README with platform-specific tips or CI-compatible examples.
License
MIT — see the LICENSE file.
