Huffman coding
Compress text with a Huffman tree, or decode a Huffman-coded container back to the original.
Huffman coding
Huffman coding is the classic compression algorithm behind formats like DEFLATE and JPEG: it counts how often each byte appears, builds a tree that gives common bytes short codes and rare bytes long codes, then rewrites the data as that string of bits. This tool builds the tree for whatever you paste in, encodes it, and decodes its own output back to the original — useful for seeing how the algorithm behaves on real text, or checking how much a message would shrink.
Set Direction to Encode or Decode. Data format is the plain side — Text reads UTF-8 characters, Hex bytes reads pairs like "48 65 6c", and Decimal bytes reads numbers from 0 to 255. Encoded format is the compressed side: Binary shows the raw 0s and 1s, Hex packs them into byte pairs, and Base64 packs them shorter still. Wrap output at N breaks a long container into readable lines without affecting decoding, since line breaks are stripped before a container is read back. Pad binary output to a full byte only matters for the Binary format — Hex and Base64 always pack to full bytes anyway.
The container carries a small header — a marker, the original length and the frequency table — so the tree rebuilds exactly on decode without shipping the tree itself. Paste a container back in with Direction set to Decode and matching formats to get the exact original bytes back, including diacritics, emoji and line endings. Very short or near-random inputs may not shrink at all, since Huffman coding only saves space when some bytes are genuinely more common than others.
Everything runs locally in your browser — nothing you paste is uploaded anywhere. Copy the result, download it as a .txt file, or send the output back into the input to decode what you just encoded.