j2r2b

My notes on GitHub pages

Follow me on GitHub

Representing a tree with ASCII or Unicode characters

Representing trees with text and a monospaced font is something I need often need to do (documentation, raising issues, …).

If your tree consists of folders and files on the filesystem, there are utilities to do it (check the tree command).

Different sets of characters can be used to represent the tree.

Unicode characters

mySite
├──css
│   └──page.css
├──images
│   └──img.svg
├──index.html
├──js
│   └──empty.js
├──other
│   └──folder
│       └──page.html
├──page1.html
└──sub
    └──page2.html

ASCII characters

mySite
+---css
|   \---page.css
+---images
|   \---img.svg
+---index.html
+---js
|   \---empty.js
+---other
|   \---folder
|       \---page.html
+---page1.html
\---sub
    \---page2.html
  • A node is using: +---
  • The last node is using: \---
  • To indent lines, if more nodes are coming: |

See also