Huffman Coding Visualizer illustration

Huffman Coding Visualizer

Huffman coding is the greedy algorithm that compression forgot to improve: repeatedly merge the two rarest symbols into one node and you get the optimal prefix-free code. Type any text and watch the tree build itself bottom-up, frequent letters ending near the root with short codes and rare ones sinking deep. The code table and the achieved compression ratio versus fixed 8-bit encoding update live as you type.

Runs 100% in your browser — simulations are computed locally on your device.

Notes

  • Building the tree greedily — always merging the two lightest nodes — provably minimises the average code length.
  • No codeword is a prefix of another, so the bitstream decodes unambiguously without separators.
  • Huffman coding is the entropy-coding stage inside ZIP, JPEG and MP3.
  • Runs 100% in your browser — simulations are computed locally on your device.