Huffman.

Build the tree, read the codebook, watch the bitstream shrink.

Source text

Everything below rebuilds as you type.

54 / 500

Load a sample

Short
Prose
Playful
Coder

Builds upward: repeatedly merges the two least probable nodes until one root is left.

Space saved
48.8%vs 8-bit
Fixed width
432bits
Huffman
221bits
Distinct symbols
20leaves
Average code
4.093bits/symbol
Entropy
4.060bits/symbol

Huffman tree

Three-dimensional Huffman tree with 20 leaves. Focus this view and use the arrow keys to orbit, plus and minus to zoom.

0left branch1right branchDepth 6 · 39 nodes

Codebook

20 symbols · 54 characters

Huffman code assigned to each distinct character
SymbolCountShareCodeBits
space71003
nn511114
oo50003
ss50013
tt410104
ee301004
ff301014
rr301104
uu301114
cc2101105
dd2101115
hh2110005
ii2110015
mm2110105
aa11101106
bb11101116
gg11110006
ll11110016
qq11110106
yy11110116

Encoded bitstream

11000011101010101110101101101111100101100001011111001111111100010010100111011011110011000101011001001110100111010011111010100001111011110101101110001110010011001100111111010000100001110000000110101010010110000101110100001

221 bits·211 saved against 432 at 8 bits per character