Question

What is the difference between lossy and lossless compression?

Vault Verified
Curated Intelligence
Definitive Source
Answer

Lossless compression can reconstruct the original data exactly. Lossy compression discards information permanently to achieve much smaller files.

Lossless works by finding and encoding redundancy more efficiently. If a file contains a long run of identical bytes, store the byte and the count. If certain patterns recur, assign them shorter codes. Decompression reverses the process perfectly — the output is bit-for-bit identical to the input.

Used where any change is unacceptable: ZIP, PNG, FLAC, ALAC, and general file archiving. You cannot lossy-compress a spreadsheet or an executable, because a single altered bit breaks it.

The limit is that redundancy is finite. Typical lossless ratios are perhaps 2:1 for text and far less for already-compressed data.

Lossy achieves dramatically better ratios — often 10:1 or more — by exploiting the limits of human perception. It does not just discard data randomly; it discards what you are least likely to notice.

JPEG exploits the eye's greater sensitivity to brightness than to colour detail, so colour information is stored at lower resolution (chroma subsampling), and fine high-frequency detail is coarsely quantised.

MP3 and AAC use psychoacoustic models: sounds masked by louder simultaneous sounds are removed entirely, as are frequencies beyond hearing.

Video codecs additionally exploit similarity between consecutive frames, storing differences rather than whole images.

The critical practical point: lossy loss is cumulative. Every save re-applies the compression, so repeatedly editing and re-saving a JPEG degrades it progressively — generation loss. Always keep a lossless master and export lossy copies. Converting an MP3 to FLAC does not restore anything; the discarded data is gone.

Modern formats do both — WebP, AVIF and HEIC offer lossless and lossy modes, and newer codecs achieve better quality at the same size than older ones.

Related Questions