Tree Generator is a VS Code extension for creating an ASCII project tree for documents such as README.md.
It starts with a directory-first, alphabetical layout and provides a Webview editor where files and folders can be reordered or excluded without modifying the filesystem.
- Generates an ASCII tree from the current workspace.
- Sorts directories first, then sorts entries alphabetically by default.
- Reorders sibling files and folders using drag and drop or move buttons.
- Adds descriptions to files and folders as aligned
# descriptioncomments. - Shows a live ASCII tree preview while editing.
- Excludes files and folders from the generated output.
- Keeps excluded entries visible, dimmed, and at the bottom of their directory.
- Toggles whether
.gitignorerules are applied from the Webview toolbar. - Refreshes open editors when files or folders are created or deleted.
- Updates marked README tree blocks automatically when the tree changes.
- Copies the edited ASCII tree to the clipboard.
- Restores the default scanned order with
Reset to default.
Example output:
tree-generator/ # VS Code extension
├── src/ # Extension source
│ ├── extension.ts # Extension entry point
│ └── treeGenerator.ts # ASCII tree generator
├── package.json # Extension manifest
└── README.md
- Open a workspace folder in VS Code.
Ctrl + Shift + Pto Open the Command Palette.- Run
Tree Generator: Open Tree Editor. - Add descriptions, arrange entries, or exclude them in the left panel.
- Use
Respect .gitignorein the toolbar to include or exclude.gitignore-matched entries. - Review the generated ASCII tree in the preview panel.
- Select
Copy treeand paste it into your document.
Descriptions, ordering, and exclusion choices are stored in .tree-generator.json and restored when the editor is opened again.
When new files or folders are discovered, they are inserted alphabetically among active entries. Existing custom ordering is preserved, and excluded entries remain at the bottom.
To let Tree Generator update README.md automatically, add a marked block. The marker comments are escaped below so this README is not treated as the generated block; remove the leading backslashes when adding the block to your document.
\<!-- tree-generator:start -->
```text
tree-generator/
└── README.md
```
\<!-- tree-generator:end -->Only the content between these markers is replaced.
Tree Generator applies root and nested .gitignore rules while scanning by default.
.gitignorenegation patterns such as!keep.logare supported.- Turn off
Respect .gitignorein the Webview toolbar to include.gitignore-matched entries. - The same behavior is available through the
tree-generator.respectGitignoreVS Code setting. - Git metadata directories named
.gitare always excluded. - Open Tree Generator editors automatically refresh when a
.gitignorefile is created, changed, or deleted. - Open Tree Generator editors also refresh when files or folders are created or deleted.
- Manual exclusions made in the Webview are separate from
.gitignorerules.
- VS Code
1.120.0or later. - An open workspace folder.
The extension also provides a CLI after the package is installed or linked:
tree-generator print
tree-generator write
tree-generator checkprintwrites the generated tree to stdout.writeupdates the markedREADME.mdtree block.checkexits with code1when the markedREADME.mdtree block is missing or out of date.- Add
--include-gitignoredto include files and folders matched by.gitignore.
tree-generator.respectGitignore: excludes files and folders matched by.gitignorewhile scanning. Defaults totrue.
- In a multi-root workspace, Tree Generator currently scans the first workspace folder.
- File content-only edits do not trigger a tree refresh because they do not change the project structure.
.tree-generator.jsonshould be committed if you want to share tree metadata with collaborators.
- Fixed the Webview
.gitignoretoggle so it can be saved per workspace folder.
- Added the visual Tree Editor and live ASCII preview.
- Added drag-and-drop ordering and manual exclusions.
- Added workspace-specific ordering and exclusion persistence.
- Added root and nested
.gitignoresupport with automatic refresh.
- Added detection of created and deleted files and folders.
- Added a Webview and setting toggle for including
.gitignore-matched entries.