tianyiliu12 downloadsTurn simple text (one line per level, parent: left right, LeetCode arrays, or indented lists) into slash-style (/ \) binary tree drawings for algorithm notes.
English | 简体中文
Turn a fixed-format text into a slash-style binary tree drawing with one command. Built for algorithm notes: the input is one line per level, parent: left right lines, a LeetCode-style level-order array, or an indented list, and the output is the / \ tree you would sketch by hand, not a ├── directory tree.
[3,9,20,null,null,15,7] → 3
/ \
9 20
/ \
15 7
Slashes are strict 45° diagonals, every parent is centered over its children, and labels of any width (including CJK characters) stay aligned at any depth.
The format is detected automatically. Pick whichever feels natural; the input dialog shows which one it recognised.
Write the root on the first line, then each level on its own line. Use | to group the children by parent, in the same order as the previous line, and _ for an empty slot.
3
9 20
_ | 15 7
9 (none) and the children of 20 (15 7).left right. _ 7 means right child only, 15 alone means left child only, and an empty group means no children.|, a line must contain exactly two values per parent, like a LeetCode array: 4 5 _ 6.A bigger example, [5,4,8,11,null,13,4,7,2,null,null,null,1]:
5
4 8
11 _ | 13 4
7 2 | | _ 1
One line per node that has children: parent: left right. The first line's parent is the root; every later parent must already appear as a child on an earlier line. Leaves are simply not mentioned.
3: 9 20
20: 15 7
If several nodes share a label, each line refers to the first such node, in order of appearance, that has not been given children yet, so writing lines level by level does the right thing.
[1,2,3,null,4]
1,2,3,null,4
1 2 3 # 4
null / None / nil / # / _ (case-insensitive, configurable). An empty string also counts as an empty slot.2i+1, 2i+2).1
2
4
5
3
null
6
null to skip the left slot.- 1) are fine. You can also set the side explicitly with L: / R::- 1
- R: 2
- 3
| Mode | How | Result |
|---|---|---|
| Convert in place | Select the text (or put the cursor on the array line) and run Convert selection to slash tree from the command palette or the right-click menu | The selection is replaced by a fenced code block containing the tree |
| Input dialog | Run Insert slash tree… | Live preview while you type; ⌘/Ctrl+Enter inserts at the cursor |
| Live rendering | Write a ```tree code block containing the source format |
Rendered as a tree in Reading view and Live Preview; the source stays editable, hover to copy |
Live rendering example:
```tree
[5,3,8,1,4,null,9]
```
More output samples:
[1,2,3,4,5,6,7] [5,3,8,1,4,null,9,null,2] [100,20,3000,1,null,null,45]
1 5 100
/ \ / \ / \
/ \ 3 8 20 3000
2 3 / \ \ / \
/ \ / \ 1 4 9 1 45
4 5 6 7 \
2
Once the plugin is listed: Settings → Community plugins → Browse, search for Slash Tree, install and enable it.
AdamLTy/obsidian-slash-tree.Download main.js, manifest.json and styles.css from the latest release, put them in <vault>/.obsidian/plugins/slash-tree/, then enable the plugin.
git clone https://github.com/AdamLTy/obsidian-slash-tree.git
cd obsidian-slash-tree
npm install
scripts/install.sh "/path/to/your/vault"
The plugin UI follows Obsidian's interface language: Chinese when Obsidian is set to 简体中文 / 繁體中文, English otherwise.
tree; reload the plugin after changing it).npm test # unit tests + property tests on random trees
npm run demo # print sample trees in the terminal
npm run dev # rebuild main.js on change
npm run build # type-check + production bundle
All layout logic lives in src/tree.ts and has no Obsidian dependency, so it can be reused on its own.