Instantly generate multi-level folder & file structures from flat text or ASCII tree format.
Stop wasting time creating nested directories manually. Scaffold entire projects in seconds! π
- β Two Input Formats: Flat file lists or tree-like ASCII structures
- π Automatic Detection: Intelligently detects format type
- π Zero Config: Works with
npx
β no global install required - π‘οΈ Safe by Default: Dry-run mode to preview before creating
- πͺ Force Mode: Overwrite existing files when needed
- π― Smart Path Handling: Correctly handles nested directories
- π‘ Perfect For: Scaffolding boilerplates, UI libraries, and project templates
- π Security: Prevents writing outside current directory
No installation needed! Run directly:
npx mkstruct structure.txt
Install once, use anywhere:
npm install -g mkstruct
Add to your project's dev dependencies:
npm install --save-dev mkstruct
Create a file structure.txt
with paths separated by slashes:
src/index.js src/components/Header.jsx src/components/Footer.jsx src/styles/main.css public/images/logo.png README.md
Generate the structure:
mkstruct structure.txt
Result:
β
Created file: src/index.js
π Created folder: src/components
β
Created file: src/components/Header.jsx
β
Created file: src/components/Footer.jsx
π Created folder: src/styles
β
Created file: src/styles/main.css
...
Create a file tree.txt
with ASCII tree structure:
βββ src β βββ index.js β βββ components β β βββ Header.jsx β β βββ Footer.jsx β βββ styles β βββ main.css βββ public β βββ images β βββ logo.png βββ README.md
Generate the structure:
mkstruct tree.txt
Note: mkstruct automatically detects which format you're using!
mkstruct [file] [options]
Option | Alias | Description |
---|---|---|
--dry-run |
-d |
Preview actions without creating files |
--force |
-f |
Overwrite existing files |
--stdin |
-s |
Read structure from stdin instead of file |
--verbose |
-v |
Enable verbose logging |
--help |
-h |
Show help information |
mkstruct structure.txt --dry-run
Output:
[DRY] create file: src/index.js
[DRY] mkdir: src/components
[DRY] create file: src/components/Header.jsx
...
cat structure.txt | mkstruct --stdin
Or create on-the-fly:
echo -e "src/index.js\nsrc/App.js\nREADME.md" | mkstruct --stdin
mkstruct structure.txt --force
mkstruct structure.txt --verbose
react-structure.txt
:
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
backend-tree.txt
:
βββ 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
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
tests/unit/utils.test.js tests/unit/components.test.js tests/integration/api.test.js tests/e2e/user-flow.test.js tests/fixtures/data.json tests/__mocks__/axios.js
# Generate from GitHub gist curl -s https://gist.githubusercontent.com/user/id/raw | mkstruct --stdin # Generate and initialize git mkstruct structure.txt && git init # Generate, install dependencies, and start mkstruct structure.txt && npm init -y && npm install express
Add to package.json
:
{ "scripts": { "scaffold": "mkstruct templates/project-structure.txt", "scaffold:preview": "mkstruct templates/project-structure.txt --dry-run" } }
Then run:
npm run scaffold
- Use forward slashes (
/
) for paths, even on Windows - Files must have an extension (e.g.,
.js
,.css
,.md
) - Folders are automatically created for nested paths
- One path per line
- Empty lines are ignored
Example:
src/index.js β File (has extension) src/utils/ β Folder (no extension, optional trailing /) config/env.json β Nested file
- Use standard tree characters:
βββ
,βββ
,β
- Each level is indented by 4 spaces or 1 tab
- Files are detected by having an extension
- The format is automatically detected
Tree Characters:
βββ
- Branch itemβββ
- Last branch itemβ
- Vertical line for nesting
Example:
project/ βββ src β βββ index.js β βββ utils β βββ helper.js βββ README.md
- mkstruct prevents writing outside the current working directory
- Paths starting with
..
or absolute paths are rejected - Always review the structure file before running with
--force
- By default, mkstruct skips existing files (shows warning)
- Use
--force
to overwrite existing files - Use
--dry-run
to preview before creating
- Use forward slashes (
/
) in structure files on all platforms - mkstruct automatically converts to Windows backslashes when needed
- Tree format works identically on Windows, Mac, and Linux
Solution: Provide a filename or use --stdin
:
mkstruct mystructure.txt # OR echo "src/index.js" | mkstruct --stdin
Solution: Make sure you're in the correct directory:
pwd # Check current directory cd /path/to/project mkstruct structure.txt
Solution: Ensure proper tree characters (βββ
, βββ
, β
) are used. Copy from examples or use a tree generator.
Solution: Don't use absolute paths or ..
in your structure file. All paths should be relative to current directory.
Contributions are welcome! Here's how you can help:
- Report Bugs: Open an issue with details
- Suggest Features: Share your ideas in issues
- Submit PRs: Fork, create a branch, and submit a pull request
- Improve Docs: Help make documentation clearer
# Clone the repository git clone https://github.com/Gitnaseem745/mkstruct.git cd mkstruct # Install dependencies npm install # Run locally node bin/index.js examples/structure.txt --dry-run
MIT Β© Naseem Ansari
See LICENSE file for details.
If mkstruct helped you save time, please give it a βοΈ on GitHub!
- GitHub: @Gitnaseem745
- NPM: mkstruct
- Issues: Report a bug
Made with β€οΈ by developers, for developers