You have a master recording or a large picture and you need it smaller. One option shrinks it and lets you recover every bit later. Another shrinks it much further but keeps only an approximation. Which one should you pick?

This guide shows what each type keeps, where the loss happens inside a real format, and what each choice does to file size. You will finish with four questions that settle the decision and a worked size calculation you can repeat with your own numbers.

What each type promises

The FLAC specification gives short definitions. Lossless compression means decompressing returns exactly the original data. Lossy compression removes, irreversibly alters or approximates information to save more space, so decompressing returns an approximation. The JPEG standard says the same thing from the decoder's side: a process is lossless when the decoder's output is identical to the encoder's input. The PNG specification defines the term in nearly the same way: a method that permits reconstruction of the original data exactly, bit for bit, so every pixel value comes back unchanged.

Question Lossless Lossy
What does decoding return? The original data, bit for bit An approximation of the original
Can the original be rebuilt from the file? Yes No
What limits the size reduction? How much pattern the data contains How much detail you are willing to drop
Example formats PNG, FLAC JPEG (its main process), MP3, AAC
Where it fits, per web-media guides Screenshots, diagrams, line art, archives, audio you will edit again Photographs, streamed audio, most video

The last row follows the guidance in MDN's image and audio guides, which add that most video codecs are lossy. The amount of loss is not fixed. It depends on the codec and how it is configured.

Where a JPEG loses detail

The JPEG standard (ITU-T T.81) lays out the lossy path in three steps. The picture is cut into 8 × 8 blocks of samples, each block goes through a transform (the discrete cosine transform, or DCT), and then a quantizer reduces the precision of the resulting numbers. The standard states that the quantizer divides and then rounds to the nearest integer. The decoder can only recover a representation of the original numbers.

Worked example. Example: three coefficients 34, 29 and 31 are quantized with a step size of 10. Each is divided by 10 and rounded: 34 ÷ 10 = 3.4 becomes 3, 29 ÷ 10 = 2.9 becomes 3, and 31 ÷ 10 = 3.1 becomes 3. The decoder multiplies by 10 and gets 30, 30 and 30. Three different values collapsed into one, so no decoder can tell which was which. That is the loss. The step size 10 is invented for the illustration.

The last stage is different. After quantizing, JPEG passes the numbers to an entropy encoder, which the standard defines as a lossless procedure. JPEG therefore works in two parts: one irreversible step that discards detail, followed by lossless coding that packs what remains into fewer bits.

What the choice does to file size

Uncompressed audio gives a clean baseline. Use the audio file size calculator or the formula sample rate × bit depth × channels × seconds ÷ 8.

Example: stereo audio at 44,100 samples per second and 16 bits per sample, 3 minutes long. The data rate is 44,100 × 16 × 2 = 1,411,200 bit/s. Over 180 seconds that is 1,411,200 × 180 ÷ 8 = 31,752,000 bytes, or 31.752 MB (1 MB = 1,000,000 bytes).

MDN's audio codec guide lists two rough limits. For lossless compression it says you are unlikely to get more than 40 to 50 percent compression. For lossy compression it says up to 80 to 95 percent is possible. Its FLAC entry reads "up to 40-50% size reduction," so these percentages mean size removed. Applying them to the example is plain arithmetic, not a measurement:

Case Size removed Result in bytes Ratio
Uncompressed 0% 31,752,000 1:1
Lossless, at the guide's limits 40% to 50% 19,051,200 to 15,876,000 1.67:1 to 2:1
Lossy, at the guide's range 80% to 95% 6,350,400 to 1,587,600 5:1 to 20:1

Each row follows from two formulas: compressed size = original × (1 − fraction removed) and ratio = original ÷ compressed. You can check any row in the compression ratio calculator. Real results shift with the material and the encoder settings. Lossy codecs nearly always produce much smaller audio than lossless codecs, according to the same guide.

Four questions that settle the choice

  1. Will you edit or re-save the file? Choose lossless. The audio guide warns that lossy damage is compounded by recompressing.
  2. Is this your only copy of the original? Keep a lossless master, then make lossy copies from it.
  3. Does every bit matter? Text, code and spreadsheets need lossless, because one changed bit can break them.
  4. Is size or bandwidth the bigger constraint? For real-time audio streaming, the guide says a lossy codec is usually required so the data keeps up with playback.

For format-by-format audio numbers, see lossless and lossy audio formats compared. For images, see JPEG vs. PNG.

Common mistakes

  • Assuming lossy always looks or sounds bad. The loss depends on the codec and its settings. MDN's guides note that more compression generally means more loss, so a lighter setting keeps more.
  • Converting a lossy file to a lossless format to "restore" it. The details were already discarded. The new file can be larger and still hold the same approximation.
  • Saving a lossy file over and over. Each pass can add new rounding on top of the old rounding. Edit from a lossless copy and export once.
  • Judging by the file type alone. One container can hold both kinds. MDN's container guide lists AAC (lossy) and FLAC (lossless) as audio codecs for MP4.
  • Quoting "50% compression" without saying which number you mean. Half the size removed is a 2:1 ratio, but 80% removed is 5:1, not 80:1. See compression ratio explained.

FAQ

Is lossless compression always bigger than lossy?

For similar material, usually yes. MDN's audio guide says lossy codecs nearly always produce significantly smaller audio. The gap depends on the settings you choose.

Can lossy compression be undone?

No. By definition the decoder returns an approximation. The discarded detail is not stored anywhere in the file.

Is JPEG always lossy?

Its common DCT-based process is lossy. The same standard also defines a separate class of lossless processes, so the name alone does not settle it.

Does lossless compression always make a file smaller?

No. A simple counting argument shows no lossless method can shrink every input. Data with no pattern may stay the same size. See why some files barely shrink.

Sources

  1. IETF, RFC 9639: Free Lossless Audio Codec (FLAC). Accessed November 6, 2026.
  2. ITU-T (copy hosted by W3C), Recommendation T.81: Digital compression and coding of continuous-tone still images. Accessed November 6, 2026.
  3. W3C, Portable Network Graphics (PNG) Specification (Third Edition). Accessed November 6, 2026.
  4. MDN Web Docs, Web audio codec guide. Accessed November 6, 2026.
  5. MDN Web Docs, Image file type and format guide. Accessed November 6, 2026.
  6. MDN Web Docs, Web video codec guide. Accessed November 6, 2026.
  7. MDN Web Docs, Media container formats (file types). Accessed November 6, 2026.