โ† Back to all tools

๐Ÿ“ฆ Compression Visualiser

See how Run-Length Encoding (RLE) and Huffman coding compress data โ€” with every step shown.

Designed with the WJEC specification in mind
CS GCSE ยง1.2.1DigiTech GCSE ยง1.1.2
๐Ÿ“ Run-Length Encoding
๐ŸŒณ Huffman Coding
๐Ÿ“– Key Concepts
๐Ÿ“

Run-Length Encoding

RLE replaces consecutive repeated characters with a count + character pair. Works best when data has long runs of the same value.

๐ŸŒณ

Huffman Coding

Huffman coding assigns shorter codes to more frequent characters. It's a variable-length, lossless compression technique.

๐Ÿ“–

Lossy vs Lossless Compression

โœ… Lossless

  • Original data can be perfectly restored
  • No quality loss
  • Examples: ZIP, PNG, FLAC, RLE, Huffman
  • Used for: text, code, spreadsheets

โš ๏ธ Lossy

  • Some data is permanently removed
  • Smaller files but quality loss
  • Examples: JPEG, MP3, MP4, AAC
  • Used for: photos, music, video
๐Ÿ’ก

When to use which?

RLE works best when data has many consecutive repeated values (e.g. simple graphics, fax documents). It can actually make data larger if there are few repeats.

Huffman coding works well when some characters appear much more often than others. The more skewed the frequency distribution, the better the compression.

Compression ratio = original size รท compressed size. Higher = better compression.