Overview
Introduction
The Unix `tree` command's box-drawing output is instantly recognizable, but you don't need a real filesystem to get that look, just a plain indented list of names.
This tool takes a simple indented list and lays it out with the same ├──, └──, and │ connectors, so you can drop a readable directory-style diagram into a README or plain-text doc.
What Is ASCII Tree Drawer?
A renderer that parses 2-space or tab indentation into a nesting depth per line, then draws the classic tree connector characters based on each item's depth and whether it's the last item at its level.
It works on any hierarchical list, not just file paths, headings, org charts, or category trees all render the same way.
How ASCII Tree Drawer Works
Each line's leading whitespace is counted in units of either one tab or two spaces to determine its nesting depth, then the remaining text is trimmed and kept as the item's label.
For every item, the tool checks whether any later item shares its depth before a shallower item appears; if not, it's the last sibling and gets a └── connector, otherwise it gets ├──, with │ columns added for ancestor levels that still have siblings pending.
When To Use ASCII Tree Drawer
Use it to sketch a directory structure, org chart, or category hierarchy as readable plain text for documentation or a code comment.
It's also useful for visually double-checking a nested outline's structure before publishing it somewhere that can't render real indentation, like a plain-text chat message.
Often used alongside ASCII Table Creator and ASCII Art Generator.
Features
Advantages
- Matches the visual style of the real Unix tree command exactly, instantly recognizable to anyone who's used a terminal.
- Supports multiple parallel root items, not just a single top-level root.
- Clear, line-specific error messages when indentation skips a level rather than silently misrendering.
Limitations
- Indentation must increase by exactly one level at a time; you can't jump from a root directly to a grandchild in one line.
- Treats every un-indented line as a separate root rather than requiring (or assuming) a single top-level root like the real tree command does.
Examples
Best Practices & Notes
Best Practices
- Stay consistent with either tabs or two-space indentation within a single list to avoid confusing depth calculations.
- Keep item labels short; long labels still render correctly but make the diagram harder to scan at a glance.
Developer Notes
Depth is computed per line by counting leading tab or 2-space units before falling back to treating the rest as trimmed label text; sibling/last-sibling status is determined by scanning forward for the next item at the same or shallower depth, the same core algorithm the real `tree` command and most tree-pretty-printers use.
ASCII Tree Drawer Use Cases
- Documenting a planned directory or file structure in a README before creating the actual files
- Sketching an org chart or category hierarchy as portable plain text
- Visualizing a nested outline's structure to catch indentation mistakes before publishing
Common Mistakes
- Skipping an indent level (e.g. going straight from 0 to 2 levels deep on one line), which is rejected rather than guessed at.
- Mixing tabs and spaces inconsistently within the same line, which can produce an unexpected depth for that line.
Tips
- If a diagram looks wrong, check for a stray extra space or tab on the offending line, indentation errors are the most common cause of unexpected connectors.
- Use the ASCII Data Table Creator instead if your data is tabular (rows and columns) rather than hierarchical.