New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details β†’ β†’
Socket
Book a DemoSign in
Socket

mkstruct

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mkstruct

πŸš€ Instantly generate nested folder & file structures from flat or ASCII tree text files. Ideal for scaffolding projects in seconds.

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

mkstruct

npm version License: MIT Node.js Version

Generate folder and file structures from plain text lists or ASCII trees in seconds.

mkstruct@2.0 ships a faster tree normalizer, smarter file detection, and a slimmer CLI tailored for everyday scaffolding workflows.

Why mkstruct v2

  • Auto-format detection – Paste a flat list or an ASCII tree; mkstruct figures it out.
  • Tree normalization – Cleans up mixed characters, tabs, and uneven spacing before parsing.
  • Robust file detection – Recognises extensionless files such as Makefile, Dockerfile, and dotfiles.
  • Safety first – Prevents writes outside the current working directory and supports dry-run previews.
  • CLI ergonomics – Zero config with npx, inline structures via -s, piping with --stdin, and verbose tracing when you need insight.

Requires Node.js 14.0.0 or newer.

Installation

Use caseCommand
Try once with npxnpx mkstruct structure.txt
Install globallynpm install -g mkstruct
Add to a projectnpm install --save-dev mkstruct

Each option exposes the same mkstruct binary.

Quick Start

Flat list input

Create structure.txt:

src/index.js
src/utils/api.js
src/components/Button.jsx
public/index.html
README.md

Generate:

npx mkstruct structure.txt

ASCII tree input

Create tree.txt:

β”œβ”€β”€ src
β”‚   β”œβ”€β”€ index.js
β”‚   β”œβ”€β”€ utils
β”‚   β”‚   └── api.js
β”‚   └── components
β”‚       └── Button.jsx
β”œβ”€β”€ public
β”‚   └── index.html
└── README.md

Generate:

npx mkstruct tree.txt

mkstruct automatically detects the format and creates folders before files so hierarchies stay intact.

CLI Reference

mkstruct [file] [options]
FlagDescription
-d, --dry-runPreview actions without touching the file system
-f, --forceOverwrite files that already exist
-s, --structure <text>Supply the structure inline (great for snippets)
--stdinRead structure from standard input (pipe support)
-v, --verboseShow parsing and normalization diagnostics
-h, --helpDisplay usage information

Common patterns

Preview output:

mkstruct structure.txt --dry-run

Pipe a remote definition:

curl -s https://example.com/structure.txt | mkstruct --stdin

Inline structure on the fly:

mkstruct -s "api/\nβ”œβ”€β”€ routes/\nβ”‚   └── users.js\n└── server.js"

Regenerate boilerplate forcefully:

mkstruct structure.txt --force

Inspect normalization behaviour:

mkstruct tree.txt --verbose

Input Guidelines

Flat format rules

  • Use forward slashes (/) to separate folders.
  • Provide one path per line; blank lines are ignored.
  • Lines with extensions are treated as files; others become folders unless they match common filenames.

ASCII tree rules

  • Use the standard characters β”œβ”€β”€, └──, and β”‚ (single- or double-dash variants both work).
  • Indent with four spaces or tabsβ€”mkstruct normalizes mixed indentation.
  • Root nodes without connectors are supported (project as the first line, for example).

Example:

project
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ index.js
β”‚   └── utils
β”‚       └── helper.js
└── README.md

Recipes

React starter

src/App.jsx
src/main.jsx
src/components/Navbar.jsx
src/components/Hero.jsx
src/components/Footer.jsx
src/pages/Home.jsx
src/pages/About.jsx
src/hooks/useAuth.js
src/utils/api.js
src/styles/globals.css
public/favicon.ico
npx mkstruct react-structure.txt

Express API tree

β”œβ”€β”€ server.js
β”œβ”€β”€ config
β”‚   β”œβ”€β”€ database.js
β”‚   └── environment.js
β”œβ”€β”€ routes
β”‚   β”œβ”€β”€ api.js
β”‚   β”œβ”€β”€ auth.js
β”‚   └── users.js
β”œβ”€β”€ controllers
β”‚   β”œβ”€β”€ authController.js
β”‚   └── userController.js
β”œβ”€β”€ models
β”‚   └── User.js
β”œβ”€β”€ middleware
β”‚   β”œβ”€β”€ auth.js
β”‚   └── errorHandler.js
└── utils
    β”œβ”€β”€ logger.js
    └── validators.js
npx mkstruct backend-tree.txt

Documentation bundle

docs/getting-started.md
docs/api/authentication.md
docs/api/endpoints.md
docs/guides/deployment.md
docs/guides/testing.md
docs/examples/basic.md
docs/examples/advanced.md

Guardrails

  • Refuses to write outside the current working directory.
  • Creates parent folders before files to avoid partial structures.
  • Skips existing files unless --force is supplied.
  • Supports dry-runs for safe previews and verbose logging for debugging.

Troubleshooting

SymptomCauseFix
Error: No input providedNo file, --stdin, or -s argument suppliedProvide a filename, pipe stdin, or use -s
Files appear in the wrong placeRan the command from the wrong directorypwd, cd into the project root, rerun
Tree format not detectedNon-standard characters or broken indentationCopy the tree glyphs exactly; run with --verbose for hints
Refusing to write outside CWDPaths contain .. or absolute segmentsEnsure all paths stay relative to the project root

Contributing

  • Fork the repo and create a feature branch.
  • Install dependencies: npm install.
  • Run tests: npm test.
  • Open a pull request referencing any related issues.
git clone https://github.com/Gitnaseem745/mkstruct.git
cd mkstruct
npm install
npm test

Bug reports and feature ideas are welcome via GitHub Issues.

License

MIT Β© Naseem Ansari

See the full text in LICENSE.

Stay in Touch

If mkstruct saves you setup time, consider dropping the repo a ⭐️.

Made with ❀️ by developers, for developers

Keywords

cli

FAQs

Package last updated on 02 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts