Brotli is Here!

Robin Watts·August 12, 2026

Optimize PDFMuPDFGhostPDLBrotliCompression
Brotli for MuPDF & Ghostscript

For the past few years, Artifex has been working with the PDF Association as part of an effort to introduce Brotli compression to the PDF format.

Last year, we co-authored a blog post with them announcing the effort to the world. The TLDR is that Brotli will allow PDFs to be smaller for the same quality. The 1,310-page Adobe PDF 1.7 reference manual - a large 30.95MB, 1,310 page PDF - is reduced to just over 13MB with Brotli. A monochrome vector-and-text document recompresses to just 50% of the original size. At archive scale, small per-file savings compound across billions of files.

Now, we’re proud to say that the proposed spec is about to be published.

Many popular PDF viewers have already been updated to cope with Brotli compression, including, of course, Ghostscript and MuPDF.

Both of these have been able to both read and write Brotli compressed PDFs for several versions.

  • MuPDF has shipped supporting Brotli as standard since 1.26.0 (May 2025).
  • Ghostscript has shipped supporting Brotli as standard since 10.06.0 (September 2025).

No changes are required to the way you use MuPDF and Ghostscript to read Brotli compressed PDFs; they seamlessly behave in the way you’d expect.

Some changes are required to create such PDFs though.

MuPDF

Existing PDFs can be recompressed losslessly using Brotli using the mutool command line tool.

mutool clean -dizzZ -e75 input.pdf output.pdf

The different flags here are as follows:

  • d decompress existing streams ready for recompression.
  • zz recompress streams using Brotli rather than Flate.
  • Z use objstms for extra space savings.
  • e the effort to use.

The amount of effort to use trades off speed versus compression. An effort of 40 will give speeds broadly equivalent to default Flate compression, for better results. An effort of 75 will give speeds broadly equivalent to maximum Flate compression, for better results. And an effort of 100 will try to wring every last ounce of compression out at the cost of noticeably longer compression times.

However long files take to compress, they will still decompress with the same blazing speed!

This is a great way to experiment with whether Brotli is useful for you in your workflow.

Users of the MuPDF C API can enable Brotli compression by setting do_compress to 2 in the pdf_write_options structure.

No changes are required to be able to read Brotli compressed PDFs.

Ghostscript

If you are using Ghostscript’s pdfwrite device to produce pdf files, you can tell it to use Brotli compression by adding -dUseBrotli to the options:

gs -o output.pdf -sDEVICE=pdfwrite -dUseBrotli input.pdf

As from v10.08.0 (due September 2026), the compression effort used for streams can be set by using -dStreamEffort, taking values from 1 to 11 (for Brotli, 1-9 for Flate).

Conclusion

The strongest argument for Brotli in PDF is not what it does to any one file but what it does to a million of them. Organisations have already accumulated data lakes running into the millions and billions of documents and data storage is growing. With Brotli being available for MuPDF and Ghostscript we can help you reduce your storage size and costs.

Small is beautiful after all!



Discuss This Article with the Community

Have a question, a different approach, or something you built after reading this? Share it on the forum or join the Discord, we'd love to hear from you.