Compression Playground
Compression looks like magic until you watch it work. This playground animates three classic algorithms over any text you type or a set of revealing samples. Run-length encoding collapses repeated characters into counts. LZ77, the dictionary scheme inside ZIP and PNG, scans forward and replaces each phrase it has seen before with a short back-reference — drawn here as an arc pointing at the earlier text being reused. Huffman coding attacks a different kind of redundancy, spending short bit codes on frequent characters and long ones on rare ones. Two size ribbons grow beneath the text in matching colours, so you can see exactly which patches of input shrank and which cost more than they saved. Feed it prose, a repetitive chorus, DNA letters or pure random noise and the ratios tell the story: compression is a measure of how much structure your data has.
Runs 100% in your browser — simulations are computed locally on your device.
Read the full guide to this tool
Notes
- Real formats stack these ideas: DEFLATE (ZIP, gzip, PNG) is LZ77 back-references followed by Huffman coding of the symbols — the two stages remove repeated phrases and uneven symbol odds in turn.
- Shannon’s source-coding theorem sets the floor: no lossless scheme can beat the entropy of the source. Random noise has maximal entropy, which is why every algorithm here leaves it the same size or bigger.
- The bit costs are simplified but honest: RLE pays 16 bits per run, LZ77 pays 9 bits per literal and 18 per back-reference, and Huffman pays its code table up front — so tiny or structureless inputs can genuinely grow.
- Runs 100% in your browser — simulations are computed locally on your device.