Glossary

Lossless Compression

A compression method that reduces file size without discarding any data — the original file is reconstructed exactly from the compressed version.

Last updated

What Is Lossless Compression?

Lossless compression is a data compression technique that reduces file size by encoding redundant patterns more efficiently — without discarding any information. Decompressing a losslessly compressed file produces a bit-for-bit identical copy of the original.

How It Works

Lossless algorithms identify and exploit patterns in data:

Run-length encoding (RLE): Replaces repeated values with a count. "AAAAAAABBB" → "7A3B". Efficient for simple graphics with large flat-colour areas.

Dictionary-based encoding (LZ77, DEFLATE): Identifies repeated sequences of bytes and replaces later occurrences with references to earlier ones. Used by ZIP, PNG, and gzip.

Entropy coding (Huffman, Arithmetic): Assigns shorter bit sequences to more frequent symbols. The most common byte value gets the shortest code.

Formats That Use Lossless Compression

FormatAlgorithmUse Case
PNGDEFLATEImages with flat colours, text, logos
ZIPDEFLATEGeneral file archives
FLACLinear prediction + entropy codingAudio
WebP losslessLZ77 variantWeb images
TIFF (LZW)LZWProfessional image archival
PDF (internally)DEFLATE for text streamsDocument text

Lossless vs Lossy: When to Choose

Choose Lossless WhenChoose Lossy When
The file will be edited againFile is a final delivery asset
Pixel-perfect accuracy is requiredFile size reduction is the priority
The file is a working copySlight quality loss is acceptable
Content is graphics, text, or codeContent is a photograph or video