PyMuPDF is a high-performance Python library, built on the MuPDF C engine, for extracting, analysing, converting, rendering and manipulating PDF and other documents, aimed at Python developers building data-extraction, document-processing and AI retrieval pipelines.
What it is
PyMuPDF is a Python binding over MuPDF, described in its README as a lightweight, fast C engine. It exposes both low-level control over document internals and high-level convenience APIs, and it ships with no mandatory external dependencies, so a single pip install pymupdf yields text extraction, rendering, conversion and page manipulation in one package. Input spans PDF and derivatives (PDF, XPS, EPUB, CBZ, MOBI, FB2, SVG, TXT, MD), raster images (PNG, JPEG, BMP, TIFF, GIF and more), Microsoft Office formats and Korean Office formats through the Pro extra, while output covers PDF, SVG and PNG/JPEG images.
The concrete problem it solves is fragmented document handling in the Python ecosystem. Text extraction, rendering, annotation, redaction, merging, splitting and format conversion are normally spread across several packages and external binaries, each with its own build and deployment requirements. PyMuPDF consolidates those tasks behind one library and one install, with pixel-accurate text extraction that carries font, colour and position metadata rather than plain strings.
Key capabilities
- High-level text extraction with font, colour and position metadata, plus table extraction (a listed topic).
- LLM-ready extraction through PyMuPDF4LLM (
pip install pymupdf4llm), producing Markdown and JSON output for RAG and AI pipelines.
- Rendering to vector SVG pages and to raster image formats such as PNG and JPEG.
- Document manipulation: read, write, annotate, redact, merge and split.
- Broad input support: PDF, XPS, EPUB, CBZ, MOBI, FB2, SVG, TXT, MD, plus PNG, JPEG, BMP, TIFF and GIF.
- Office and Korean Office input (DOC, DOCX, XLS, XLSX, PPT, PPTX, HWP, HWPX) via the
pymupdfpro extra.
- OCR for scanned pages and images through Tesseract, and an extended font collection via
pymupdf-fonts.
Who uses it and how
- AI and RAG pipelines that need Markdown or JSON text from PDFs; the README states the project powers AI pipelines worldwide.
- Data-science and analytics teams doing bulk text and table extraction from large document sets, one of its declared topics.
- Digitisation and archival workflows that OCR scanned pages with Tesseract before indexing.
- Back-office conversion jobs that turn Office or HWP documents into PDF at full fidelity using
pymupdfpro.
- Embedded deployments in containers and batch services, since the core library needs no external services and no mandatory dependencies.
Getting started
Install with pip install pymupdf. Pre-built wheels cover Windows, macOS and Linux on Python 3.10–3.14; where no wheel exists, pip compiles from source and a C/C++ toolchain is required.
How it compares
The facts provided name no paid products this project replaces, and no comparable Python tools. MuPDF appears only as the C engine PyMuPDF is built on, not as an alternative. On the evidence supplied here, it stands alone in this registry.
When to use it — and when not to
A self-hoster operates no database, storage or SMTP service, but optional features bring their own requirements: OCR needs Tesseract installed separately (brew install tesseract, sudo apt install tesseract-ocr), Office support needs the pymupdfpro extra, and platforms without a pre-built wheel must provide a C/C++ toolchain. The licence is AGPL-3.0, so teams shipping closed-source products that cannot meet AGPL obligations should look elsewhere. Those needing Office conversion without the Pro extra, or OCR without an extra system package, should also plan around those gaps.
project readme (upstream, from github) — read inline
PyMuPDF

The PDF engine behind over 50 million monthly downloads, powering AI pipelines worldwide.
PyMuPDF is a high-performance Python library for data extraction, analysis, conversion, rendering and manipulation of PDF (and other) documents. Built on top of MuPDF — a lightweight, fast C engine — PyMuPDF gives you precise, low-level control over documents alongside high-level convenience APIs. No mandatory external dependencies.

Why PyMuPDF?
- Fast — powered by MuPDF, a best-in-class C rendering engine
- Accurate — pixel-perfect text extraction with font, color, and position metadata
- Versatile — read, write, annotate, redact, merge, split, and convert documents
- LLM-ready — native Markdown output via PyMuPDF4LLM for RAG and AI pipelines
- No mandatory dependencies —
pip install pymupdf and you're done
Installation
pip install pymupdf
Wheels are available for Windows, macOS, and Linux on Python 3.10–3.14. If no pre-built wheel exists for your platform, pip will compile from source (requires a C/C++ toolchain).
Optional extras
# More fonts
pip install pymupdf-fonts
# LLM-ready extraction
pip install pymupdf4llm
# Office support
pip install pymupdfpro
# OCR (Tesseract must be installed separately)
# macOS
brew install tesseract
# Ubuntu / Debian
sudo apt install tesseract-ocr
Supported File Formats
Input
Output
Quick start
Extract text
import pymupdf
doc = pymupdf.open("document.pdf")
for page in doc:
print(page.get_text())
Extract text with layout metadata
import pymupdf
doc = pymupdf.open("document.pdf")
page = doc[0]
blocks = page.get_text("dict")["blocks"]
for block in blocks:
if block["type"] == 0: # text block
for line in block["lines"]:
for span in line["spans"]:
print(f"{span['text']!r} font={span['font']} size={span['size']:.1f}")
Extract tables
import pymupdf
doc = pymupdf.open("spreadsheet.pdf")
page = doc[0]
tables = page.find_tables()
for table in tables:
print(table.to_markdown())
# or get as Pandas DataFrame
df = table.to_pandas()
Render a page to an image
import pymupdf
doc = pymupdf.open("document.pdf")
page = doc[0]
pixmap = page.get_pixmap(dpi=150)
pixmap.save("page_0.png")
OCR a scanned document
import pymupdf
doc = pymupdf.open("scanned.pdf")
page = doc[0]
# Requires Tesseract installed and on PATH
text = page.get_textpage_ocr(language="eng").extractText()
print(text)
Convert Markdown to PDF
import pymupdf
md_doc = pymupdf.open("example.md")
md_doc.save("example.pdf")
Convert to Markdown for LLMs
import pymupdf4llm
md = pymupdf4llm.to_markdown("report.pdf")
# Pass directly to your LLM or vector store
print(md)
Annotate and redact
import pymupdf
doc = pymupdf.open("contract.pdf")
page = doc[0]
# Add a highlight annotation
rect = pymupdf.Rect(72, 100, 400, 120)
page.add_highlight_annot(rect)
# Add a redaction and apply it
page.add_redact_annot(rect)
page.apply_redactions()
doc.save("contract_redacted.pdf")
Merge PDFs
import pymupdf
merger = pymupdf.open()
for path in ["part1.pdf", "part2.pdf", "part3.pdf"]:
merger.insert_pdf(pymupdf.open(path))
merger.save("merged.pdf")
Convert an Office document to PDF
import pymupdf.pro
pymupdf.pro.unlock("YOUR-LICENSE-KEY")
doc = pymupdf.open("presentation.pptx")
pdf_bytes = doc.convert_to_pdf()
with open("output.pdf", "wb") as f:
f.write(pdf_bytes)
Extract LLM-ready Markdown from a Word document
import pymupdf4llm
import pymupdf.pro
pymupdf.pro.unlock("YOUR-LICENSE-KEY")
md = pymupdf4llm.to_markdown("document.docx")
print(md)
Features
Core capabilities
LLM & AI output (via PyMuPDF4LLM)