Home / Calculators / Data Compression Simulator
Free online tool

Data Compression Simulator

Explore Huffman coding for text. Compare UTF-8 bits and encoded payload, inspect the code table and copy results. Educational, with no archive output.

Start using

What the numbers mean

The simulator counts symbols by Unicode code point and builds a binary Huffman tree by combining the two least frequent nodes. A single distinct symbol receives code 0. The same exact input gives the same codes in this implementation. Tied frequencies can produce different valid codes with another tie-breaking order; compare weighted payload length rather than assuming one universal code table.

Examples you can enter

ABBC gives B=0, A=10 and C=11: 2×1 + 1×2 + 1×2 = 6 payload bits, compared with 32 UTF-8 bits. AAAA gives 32 original bits and 4 payload bits. 你好 gives 48 and 2 bits; the actual text 😀😀 gives 64 and 2 bits.

Input and display

The limit is 100,000 JavaScript UTF-16 code units, rather than UTF-8 bytes or visible characters. Many emoji use two units, and a visible emoji sequence can contain multiple code points. Empty text is rejected, but whitespace is valid data. JSON notation displays a line break as \n and a tab as \t; an ordinary space is a quoted space, " ". This representation does not change the input symbol.

Limits of this demonstration

Original bits are the UTF-8 byte length multiplied by eight. Payload bits are the sum of each symbol’s frequency times its code length. The payload excludes the codebook, tree, headers, padding and container overhead. It is not a compressed file size or a guaranteed real-world saving. The tool produces no archive, downloadable compressed binary or decompressor, and it is not encryption. Calculation stays in the browser. Large distinct-symbol sets can create long result tables.

Processing takes place locally in your browser.