Create directory and file structures from any input format. Transform ASCII trees, JSON objects, or path arrays into real filesystem structures.
Autofold supports various input formats to match your workflow
Convert beautiful ASCII tree diagrams directly into folder structures
Use nested or flat JSON objects to define your directory structure
Simple arrays of paths or path segments for quick structure creation
Get up and running in seconds
bun add autofold@latest
bunx autofold@latest -f tree "./project
├── src
│ ├── index.ts
│ └── utils
│ └── helper.ts
└── package.json"
import { transformTreeString, createStructure } from 'autofold';
const treeString = `project
├── src
│ ├── index.ts
│ └── utils
│ └── helper.ts
└── package.json`;
const nodes = transformTreeString(treeString);
await createStructure(nodes[0], './output');
See Autofold in action with different input formats
autofold -f tree "./project
├── src
│ ├── index.ts
│ └── utils
│ └── helper.ts
└── package.json"
autofold -f nested '{
"project": {
"src": {
"index.ts": null,
"utils": {
"helper.ts": null
}
},
"package.json": null
}
}'
autofold -f paths '[
"project/src/index.ts",
"project/src/utils/helper.ts",
"project/package.json"
]'
Complete library functions and types
transformTreeString()
Parse ASCII tree strings
transformNestedTree()
Parse nested JSON objects
createDirectoryTree()
Parse path arrays
createStructure()
Generate filesystem structure
type FolderNode = {
type: 'folder' | 'file';
name: string;
children?: FolderNode[];
};
type NestedTree = {
[key: string]: null | string | NestedTree;
};