Do you want to draw a tree in plain text?

Yuchen Z.
Jul 24, 2022

--

Photo by Adarsh Kummur on Unsplash

Have you ever deal with tree structure in your career as an engineer? Is there a time when you want to leave some comments about the tree structure in code?

I just built this little tool ascii_tree that can render a tree (defined with markdown format) with some ASCII characters.

How To Use

Step 1. Define the tree structure in markdown format and save that in a file (i.e. tree.md):

#Root
##Child 1
##Child 2

Step 2. Render:

$ ascii_tree --input tree.md
┌──────┐
│ Root │
└──┬───┘
┌─────┴──────┐
┌────┴────┐ ┌────┴────┐
│ Child 1 │ │ Child 2 │
└─────────┘ └─────────┘

Source code in GitHub https://github.com/yzhong52/ascii_tree. All built in Rust. I would love some feedback and contributions are welcome too!

--

--