Lossy compression shrinks files by permanently removing some data, while lossless compression shrinks files in a way that lets you reconstruct the original perfectly. That single distinction drives nearly every decision about how photos, music, video, and documents get stored and shared. The trade-off is straightforward: lossy files are much smaller but can never be restored to their original quality, while lossless files are larger but preserve every bit of the source material.
How Lossless Compression Works
Lossless compression finds patterns and redundancies in data, then represents them more efficiently. Think of it like shorthand. Instead of writing “AAAAAABBBB,” you could write “6A4B” and convey the same information in fewer characters. That basic idea, called run-length encoding, is one of the simplest lossless techniques.
More sophisticated methods work on similar principles. Huffman coding assigns shorter codes to symbols that appear frequently and longer codes to rare ones. If the letter “e” shows up constantly in a text file, it gets a compact code, while “z” gets a longer one. The result is a smaller file that still contains all the original information. A related approach called LZW (used in formats like GIF and early ZIP files) builds a dictionary on the fly as it reads through data. It spots recurring sequences, assigns each one a short reference code, and transmits those codes instead of the full sequences. The clever part: the decoder can rebuild the same dictionary from the compressed stream alone, so the dictionary itself never needs to be included in the file.
The compression ratios for lossless methods are modest compared to lossy ones. A lossless algorithm might cut a file to 50-60% of its original size, depending on how much redundancy exists. Files with lots of repetition (like spreadsheets or simple graphics) compress well. Files that are already compressed or highly random barely shrink at all.
How Lossy Compression Works
Lossy compression takes a fundamentally different approach: it figures out which parts of the data you probably won’t notice are missing, then throws them away. The core operation is called quantization. Instead of storing a precise value for every data point, quantization rounds groups of nearby values to a single representative value. If 50 slightly different shades of blue appear in a patch of sky, quantization might reduce them to 5 shades. The file gets dramatically smaller, and to your eye, the sky looks the same.
Most lossy compression also uses a mathematical step called a transform that converts raw data (pixel colors, sound waves) into a frequency-based representation. This separates the broad, important patterns from fine details and noise. The compressor can then aggressively discard the fine details while keeping the broad patterns intact. JPEG images, MP3 audio, and most video codecs all rely on some version of this transform-then-quantize pipeline.
The key variable is how aggressively the algorithm quantizes. Most lossy formats let you choose a quality setting that controls this balance. A JPEG saved at 95% quality is nearly indistinguishable from the original but only modestly smaller. The same image at 30% quality is tiny but visibly blocky and smeared. One important caution: every time you open a lossy file, edit it, and save it again, you lose more quality. The degradation compounds with each cycle.
Why Lossy Compression Looks and Sounds Fine
Lossy algorithms aren’t just removing data at random. They’re specifically targeting information your eyes and ears can’t detect, guided by decades of research into human perception. Your visual system is far more sensitive to changes in brightness than to changes in color. JPEG and similar formats exploit this by compressing color information much more aggressively than brightness information. The quantization values for color channels are deliberately set higher because, as psychovisual research confirms, your eyes treat color detail as significantly less important.
Audio compression works the same way. Human hearing requires different loudness levels to detect sounds at different frequencies. You’re most sensitive to sounds between roughly 2 kHz and 5 kHz (the range of speech), and much less sensitive at very low or very high frequencies. MP3 and AAC encoders use psychoacoustic models based on this sensitivity curve to decide what to keep and what to discard. Sounds that fall below your hearing threshold at a given frequency, or sounds that are masked by louder nearby sounds, get stripped out. The result is a file that’s a fraction of the original size but sounds identical to most listeners at reasonable bitrates.
Common Lossy Formats
JPEG remains the most widely used lossy image format. It’s excellent for photographs because photos contain the kind of smooth gradients and complex color information that lossy compression handles well. JPEG lets you control the quality-to-size balance, and for web use, a well-compressed JPEG is typically far smaller than its lossless equivalent with no visible difference at normal viewing sizes.
For audio, MP3 is the most recognized lossy format, though AAC (the format behind most M4A files) generally delivers better quality at the same file size. A high-quality lossy audio stream typically runs around 256 kilobits per second. At that bitrate, most people can’t distinguish the compressed version from the original in casual listening. WebP, a newer image format from Google, outperforms JPEG for lossy photo compression, producing smaller files at equivalent visual quality.
Video formats like H.264 and H.265 are lossy by nature. Raw video files are enormous, so lossy compression isn’t optional for video. It’s essential.
Common Lossless Formats
PNG is the standard lossless image format for the web. It uses 24-bit color and handles transparency well, making it the go-to choice for graphics, logos, screenshots, and any image where sharp edges and exact colors matter. PNG files are larger than JPEGs for photographs, but for images with flat colors and text, PNG can actually produce smaller files than JPEG while looking crisper.
FLAC is the dominant lossless audio format. It preserves every detail of the original recording while cutting file sizes to roughly 50-60% of the uncompressed original (WAV). FLAC files are significantly larger than MP3 or AAC files, but for archival purposes or audiophile listening, there’s zero quality compromise. ZIP and its variants handle lossless compression for general files: documents, code, databases, and anything where losing even a single bit would be unacceptable.
Choosing Between Lossy and Lossless
The choice comes down to what the data is and what you’re doing with it. Use lossless when accuracy matters: medical imaging, legal documents, software distribution, audio mastering, archival storage, or any situation where you’ll need to edit the file again later. Use lossy when file size matters and small quality reductions are acceptable: sharing photos online, streaming music, sending video, or storing large media libraries on limited storage.
- Photos for the web or social media: JPEG or WebP (lossy). The size savings are massive and the quality loss is invisible at typical viewing sizes.
- Graphics, logos, or screenshots: PNG (lossless). Sharp edges and text look terrible with lossy compression.
- Music for everyday listening: MP3 or AAC at 256 kbps (lossy). Indistinguishable from lossless for most people.
- Music archiving or production: FLAC or WAV (lossless). Preserves full quality for future use.
- Documents, spreadsheets, code: ZIP or similar (lossless). Lossy compression would corrupt the data.
Newer Formats That Do Both
Some modern formats blur the line by supporting both lossy and lossless modes. WebP can compress images losslessly (outperforming PNG in file size) or in lossy mode (outperforming JPEG). JPEG XL, a newer open-source format designed to eventually replace JPEG, supports lossy and lossless compression, HDR, transparency, and progressive loading. It can even losslessly transcode existing JPEG files into smaller JPEG XL files without any additional quality loss. For a typical 24-megapixel photo, JPEG XL produces files around 3 to 7 MB depending on the compression mode. Its main limitation right now is adoption: browser and software support is still catching up.
AAC, the audio format used in Apple’s ecosystem, also supports both lossy and lossless encoding. Apple Music’s lossless tier uses this capability to deliver full-quality audio alongside its standard compressed streams.

