Home / Glossary / What is lossless compression?

Glossary

What is lossless compression?

Lossless compression shrinks a file without losing a single bit of the original data. When you decompress it, you get back an exact copy — every pixel, every sound sample, every word. PNG images and FLAC audio are the best-known examples.

What is lossless compression?

Lossless compression is a way of making files smaller that never throws information away. The compressed file is a shorter description of the same data, and the decoder rebuilds the original bit for bit. That is the key difference from lossy compression, used by JPEG and MP3, which deletes detail the eye or ear is unlikely to notice. Lossy files are smaller, but the deleted detail is gone forever. With lossless compression, there is no quality trade-off at all — only a smaller saving.

How lossless compression works

Lossless methods work by finding patterns and storing them once. If a row of pixels repeats the same colour two hundred times, the file stores the colour and the count instead of two hundred copies — a trick called run-length encoding. Dictionary methods replace repeated phrases with short codes that point back to the first copy. Prediction methods guess each value from the ones before it and store only the small difference. These tricks stack: a typical PNG is 20–50% smaller than the same image stored raw, and text files often shrink by 60–70% or more.

Lossless vs lossy

Choose lossless when the original must survive untouched: masters, archives, text, logos with sharp edges, and images that will be edited again later. Each lossy save loses a little more detail, so editing a JPEG again and again slowly degrades it, while a PNG can be opened and saved any number of times with no change. Choose lossy when small size matters more than exactness — photos shared online, streamed music, video — because lossy formats can shrink files to a tenth of their original size, far beyond what lossless can do.

When to use lossless compression

Use lossless formats for anything you plan to keep, edit or print: PNG for screenshots, logos and graphics, FLAC for music masters, and ZIP for documents and code. Use lossy formats for final delivery where size matters — a JPEG photo on a website, an MP3 on a phone. A simple rule covers most cases: keep the lossless original, and make a lossy copy only for sharing.

Compress images without losing quality. Shrink PNG and other images in your browser — files never leave your device.