Skip to content

MozJPEG

Mozilla's improved JPEG encoder — same JPEG format, about 5% smaller files on average at equal quality, by Mozilla’s own measurement.

On this page

Definition

MozJPEG is a JPEG encoder maintained by Mozilla. It improves on the standard libjpeg encoder with trellis quantization (choosing coefficients that compress better at equal visual quality) and progressive encoding, producing JPEGs that Mozilla measured at about 5% smaller on average than libjpeg-turbo at the same visual quality (some images shrink more) while remaining 100% standard JPEG files.

In practice

Because MozJPEG output is a standard JPEG, it works everywhere JPEG works — no browser or tool changes needed. ImageAlchemy uses MozJPEG for its JPEG output path.

Source for the size figure: Mozilla’s MozJPEG 2.0 announcement (July 2014), which reports that MozJPEG 2.0 “can reduce file sizes … by 5% on average” compared with libjpeg-turbo.

Why the encoder matters more than the format

People discuss image formats as though the format decides the file size. It does not. The encoder decides, and JPEG is the clearest example.

JPEG has been a fixed standard since 1992. Any compliant encoder produces files that every decoder reads. What the standard does not dictate is how hard the encoder works to choose good coefficients — and that is where MozJPEG’s saving comes from. Two encoders can produce mathematically valid JPEGs from the same source, at the same quality setting, with visibly different file sizes.

MozJPEG is essentially libjpeg with a great deal more effort spent on those choices. To you this is pure gain: smaller files, identical compatibility, no quality trade-off. There is no downside beyond slightly slower encoding.

Progressive and baseline JPEG

The other MozJPEG improvement is less obvious but affects perceived speed.

Baseline JPEG stores the image top to bottom. A slow connection shows it filling in from the top, like a curtain being drawn down.

Progressive JPEG stores several passes at increasing detail, so the whole image appears blurry almost immediately and then sharpens. Same final quality, same file size class, but the page feels faster because the visitor sees something meaningful sooner.

Progressive is the better default for web use, and MozJPEG enables it. Note that progressive JPEGs are slightly more expensive to decode, which matters only on very constrained devices and rarely outweighs the perceptual benefit.

Compress your images now — free and private

Process up to 200 images locally. Choose a format, compare the results and download a ZIP.

Open the compressor
100% private No signup

Frequently asked questions

MozJPEG is an improved JPEG encoder. Using trellis quantization and progressive encoding, it produces standard JPEG files that are about 5% smaller on average than libjpeg-turbo output at the same visual quality, according to Mozilla; some images shrink more.

No. MozJPEG output is a 100% standard JPEG file — every browser, editor and device reads it. The improvement is purely in how the file is encoded, not in the format itself.

Yes. MozJPEG is open source, maintained by Mozilla, and royalty-free to use. ImageAlchemy uses it as its JPEG encoder.

Two likely reasons. The encoder may be a basic one — the same JPEG can differ by several percent in size depending on how much effort the encoder spends, which is what MozJPEG improves. Or the image dimensions are simply too large; reducing pixel width usually saves far more than any encoder setting.

A JPEG encoding that stores several passes of increasing detail, so the whole image appears blurred almost immediately and then sharpens. A baseline JPEG fills in from the top instead. Progressive files feel faster to load at the same final quality, and MozJPEG produces them.

WebP if you can serve it, since it is smaller still and now universally supported. Keep MozJPEG-encoded JPEG as the fallback inside a <picture> element — it is the best version of the one format every browser on earth understands.