MuPDF is the lightweight, high-performance PDF renderer and tool suite from Artifex (the same company behind Ghostscript). Where Ghostscript is the heavyweight all-purpose engine, MuPDF is built for speed and a small footprint. For viewing, rendering, and basic manipulation, MuPDF often outperforms its larger siblings. This guide is an introduction.
What MuPDF is
MuPDF is:
- A C library for parsing and rendering PDF, XPS, and several ebook formats
- A standalone viewer (
mupdformupdf-gl) - A CLI tool (
mutool) for manipulating PDFs - An Android viewer app and Java bindings
The library is the foundation; mutool and the viewer are convenient front-ends.
MuPDF is licensed under AGPL (open source) or commercial license (for proprietary apps).
Installing MuPDF
Debian / Ubuntu:
sudo apt install mupdf mupdf-tools
Fedora:
sudo dnf install mupdf mupdf-tools
macOS:
brew install mupdf
Windows:
Download from mupdf.com or use Chocolatey: choco install mupdf.
After install, the mupdf (viewer) and mutool (CLI) commands are available.
The mupdf viewer
A minimal PDF viewer:
mupdf input.pdf
Features:
- Keyboard-driven navigation (j/k for next/prev page, +/- zoom, / search)
- Fast rendering
- Low memory footprint
- Anti-aliasing
- Multi-page view
For Linux users who want a fast, no-frills PDF viewer, mupdf is excellent.
For X11 systems, there is also mupdf-x11. For OpenGL-accelerated rendering, mupdf-gl.
mutool: the CLI toolkit
The real power of MuPDF as a tool comes from mutool.
Subcommands:
mutool draw, render to image or other formatsmutool show, display PDF structuremutool extract, extract embedded resourcesmutool clean, clean up and optimizemutool convert, convert between formatsmutool merge, merge PDFsmutool create, create PDFs from text and imagesmutool poster, split pages into smaller pagesmutool pages, show page count and dimensionsmutool info, display info about pages and fonts
Each subcommand has its own options. Discover them with mutool <command> -h.
Common operations
Render pages to PNG:
mutool draw -r 150 -o page-%d.png input.pdf
-r 150 sets 150 DPI. %d in the output filename is the page number.
For specific pages:
mutool draw -r 300 -o page-%d.png input.pdf 1,3,5
See how to convert a PDF to image.
Render to multi-page PDF (compressed):
mutool clean -gggg input.pdf compressed.pdf
The -gggg flag enables maximum cleanup and compression. See reduce PDF file size.
Merge PDFs:
mutool merge -o combined.pdf file1.pdf file2.pdf file3.pdf
Split a PDF:
mutool draw -F pdf -o page-%d.pdf input.pdf 1,2,3
Each page becomes a single-page PDF. See how to split a PDF.
Extract text:
mutool draw -F text -o text.txt input.pdf
Or for structured text:
mutool draw -F stext -o text.xml input.pdf
For comparison: poppler's pdftotext is often used for the same job, see poppler-utils introduction.
Show PDF structure:
mutool show input.pdf trailer
mutool show input.pdf catalog
mutool show input.pdf pages
Reveals the file's internal structure.
Extract embedded images:
mutool extract input.pdf
Each image becomes a separate file in the current directory.
Convert to HTML:
mutool convert -F html -o output.html input.pdf
Convert to EPUB:
mutool convert -F epub -o output.epub input.pdf
See how to convert a PDF to EPUB.
Clean up a PDF:
mutool clean -gg input.pdf cleaned.pdf
Removes unused objects, sanitizes content streams. Multiple -g flags increase aggressiveness.
Linearize for fast web view:
mutool clean -l input.pdf linearized.pdf
See linearized PDF and fast web view.
Decompress for inspection:
mutool clean -d input.pdf inspectable.pdf
Decompresses content streams so they are human-readable. Useful for debugging.
Page info
mutool info input.pdf
Shows page count, dimensions, fonts, images, and more.
mutool pages input.pdf
Just lists pages with their boxes.
Performance
MuPDF's main appeal is speed. On the same hardware:
- Rendering is typically 2-5x faster than Ghostscript for raster output
- Loading large PDFs is faster
- Memory usage is lower
- Startup time is essentially instant
For pipelines that render or convert at scale, MuPDF is often the right engine.
When to use MuPDF vs alternatives
- MuPDF/mutool for fast rendering and cleanup, best raw speed
- Ghostscript for complex compression and conversion, see Ghostscript introduction
- qpdf for structural operations, see qpdf introduction
- pdftk for forms and stamps, see pdftk introduction
- poppler-utils for text extraction, see poppler-utils introduction
Many production pipelines use MuPDF for rendering and Ghostscript for compression.
Specific use cases
Server-side PDF preview generation:
mutool draw -r 100 -o /tmp/preview-%d.png /tmp/input.pdf
Generates thumbnails for a web app. Fast enough for real-time response.
Batch cleanup of a PDF library:
for f in *.pdf; do
mutool clean -gggg "$f" "cleaned/$f"
done
Convert a library to EPUB for ebook readers:
for f in *.pdf; do
mutool convert -F epub -o "epub/${f%.pdf}.epub" "$f"
done
Inspect a suspicious PDF:
mutool show input.pdf trailer
mutool show input.pdf catalog
mutool clean -d input.pdf inspectable.pdf
less inspectable.pdf
Decompress and inspect the raw structure.
Integration with applications
MuPDF's library is embeddable. Many applications use it:
- Sumatra PDF (Windows reader) is built on MuPDF
- Various mobile PDF apps use MuPDF for rendering
- Custom server applications can use MuPDF for fast PDF processing
The Python binding PyMuPDF (also called fitz) brings MuPDF to Python:
import fitz # PyMuPDF
doc = fitz.open("input.pdf")
for page in doc:
pix = page.get_pixmap(dpi=150)
pix.save(f"page-{page.number+1}.png")
PyMuPDF is one of the fastest Python PDF libraries.
Common gotchas
Subcommand syntax. mutool draw -F pdf produces a PDF; mutool draw -F png produces PNG. The -F (format) flag is crucial.
Output file format. Specify with -o filename and the format is inferred from extension. For -F, must specify the format explicitly.
Page selection syntax. Pages can be specified as 1,2,3 or 1-5 after the input filename.
Encryption. Use -p password to provide a password for encrypted PDFs.
Color management. Less mature than Ghostscript for color-critical work. For prepress, Ghostscript is the safer choice.
Forms. MuPDF can render forms but not directly fill them. Use pdftk for form filling.
Memory on huge PDFs. Generally lower than Ghostscript, but still bounded. For multi-GB PDFs, process in chunks.
License. AGPL by default. For embedding in commercial software, license from Artifex.
Strengths and weaknesses summary
Strengths:
- Fast rendering
- Low memory footprint
- Multi-format output (PNG, JPEG, PDF, SVG, HTML, EPUB, text)
- Built-in viewer
- Active development
- Mature Python binding (PyMuPDF)
Weaknesses:
- No form filling
- Less color management depth than Ghostscript
- AGPL license restricts some commercial use
- Smaller community than poppler
Practical recipe
For a typical MuPDF workflow:
- Inspect:
mutool info input.pdf - Render:
mutool draw -r 150 -o page-%d.png input.pdf - Or convert:
mutool convert -F epub -o output.epub input.pdf - Or clean:
mutool clean -gggg input.pdf cleaned.pdf
Takeaway
MuPDF is the fast, lean PDF engine that excels at rendering, conversion, and cleanup. mutool provides a focused CLI for batch operations and pipelines. For high-throughput PDF processing, MuPDF often outperforms heavier alternatives. For interactive operations and ad-hoc conversions, Docento.app handles many similar tasks in a browser. For the broader CLI toolchain, see Ghostscript introduction, qpdf introduction, pdftk introduction, and poppler-utils introduction. Combined, these tools cover essentially every PDF workflow on Unix-like systems.