text → treeA PREORDER PLAYGROUND

A little text.
A three-way tree.

Build a ternary tree, then visit its nodes in preorder to read your text back.

01 Your text

0 / 300 symbols

Spaces, line breaks and emoji stay intact. Up to 300 text symbols.

02 The tree

No nodes yet

100%
Ternary treeBuild a tree to explore its preorder traversal.
Current node Visited␣ space · ↵ line break · ⇥ tabBranch labels: L / M / R
Accessible node list & branch structure

    03 Read it back

    —

    Ready.

    The output comes from traversing the tree, not copying the input field.

    Why does it work?

    Each node holds one text symbol. The first symbol becomes the root. The remaining symbols are split into up to three consecutive groups of similar size, and each group is built the same way.

    Preorder visits the root, then the entire left subtree, then the middle subtree, then the right subtree. Because each group keeps its original order, the traversal recovers the exact text. There are many valid trees; this is one compact, balanced arrangement.

    Emoji and combined characters are grouped as graphemes where your browser supports it. The visible whitespace marks are only labels; the actual output preserves the original characters.