npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

tree2folder

v1.0.8

Published

Generate a directory structure from a text tree diagram

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!

tree2folder demo

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 tree2folder

After installation, you can use it directly:

tree2folder <file-name> [<directory>]

Examples

  1. Basic example (create structure in current directory)

Create diagram.txt with this content:

project
├─ bin/
│  └─ start.sh
├─ src/
│  ├─ index.js
│  └─ helpers.js
└─ README.md

Or

project
    bin/
        start.sh
    src/
        index.js
        helpers.js
    README.md

Then run:

npx tree2folder diagram.txt

Result: a project folder containing the described files and folders.

  1. Create into a specific directory
npx tree2folder diagram.txt ./output-folder

This 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.md

Behavior & tips

  • Lines ending with / are treated as directories. Indentation (spaces) defines nesting.
  • Tree characters like ├─, └─, and are ignored, so you can paste output from tree or 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-run flag to preview what will be created without making changes.
  • Add --force to overwrite existing files and a --yes flag to skip prompts.
  • Improve the README with platform-specific tips or CI-compatible examples.

License

MIT — see the LICENSE file.