PyMuPDF is a free, open source publishing project written in Python and released under AGPL-3.0. It has 10,732 GitHub stars, 798 forks and 58 open issues, and was last pushed 7 hours ago. On this registry it ranks #9 of 46 tracked projects in Publishing, with 5 head-to-head comparisons available. It gained 15 stars over the last 3 tracked days.

What is PyMuPDF?

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

PyMuPDF

pymupdf%2FPyMuPDF | Trendshift

Docs PyPI Version PyPI - Python Version License AGPL PyPI Downloads Github Stars Discord Forum Twitter Hugging Face Demo

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.

Star on GitHub


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 dependenciespip 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

Package Purpose
pymupdf-fonts Extended font collection for text output
pymupdf4llm LLM/RAG-optimised Markdown and JSON extraction
pymupdfpro Adds Office document support
tesseract-ocr OCR for scanned pages and images (separate install)
# 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

Category Formats
PDF & derivatives PDF, XPS, EPUB, CBZ, MOBI, FB2, SVG, TXT, MD
Images PNG, JPEG, BMP, TIFF, GIF, and more
Microsoft Office (Pro) DOC, DOCX, XLS, XLSX, PPT, PPTX
Korean Office (Pro) HWP, HWPX

Output

Format Notes
PDF Full fidelity conversion from Office formats
SVG Vector page rendering
Image (PNG, JPEG, …) Page rasterisation at any DPI
Markdown Structure-aware, LLM-ready
JSON Bounding boxes, layout data, per-element detail
Plain text Fast, lightweight extraction

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

Feature Description
Text extraction Plain text, rich dict (font, size, color, bbox), HTML, XML, raw blocks
Table detection find_tables() — locate, extract, and export tables as Markdown or structured data
Image extraction Extract embedded images and render any page to a high-resolution Pixmap
Rendering Render PDF pages to images or Pixmap data for use in UI or other workflows
OCR Tesseract integration — full-page or partial OCR, configurable language
Annotations Read and write highlights, underlines, squiggly lines, sticky notes, free text, ink, stamps
Redaction Add and permanently apply redaction annotations
Forms Read and fill PDF AcroForm fields
PDF creation Create PDFs directly with the API or quickly convert from Markdown files
PDF editing Insert, delete, and reorder pages; set metadata; merge and split documents
Drawing Draw lines, curves, rectangles, and circles; insert HTML boxes
Encryption Open password-protected PDFs; save with RC4 or AES encryption
Links Extract hyperlinks, internal cross-references, and URI targets
Bookmarks Read and write the outline / table of contents tree
Metadata Title, author, creation date, producer, subject, and custom entries
Color spaces RGB, CMYK, greyscale; color space conversion

LLM & AI output (via PyMuPDF4LLM)

Output API
Markdown pymupdf4llm.to_markdown(path)
JSON pymupdf4llm.to_json(path)

readme truncated — read the full docs on github

Frequently asked questions

Is PyMuPDF free to use?

PyMuPDF is open source under the AGPL-3.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does PyMuPDF do?

PyMuPDF is a high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents.

What is PyMuPDF written in?

PyMuPDF is primarily written in Python. Its source is publicly available at https://github.com/pymupdf/PyMuPDF, and it has 10,732 GitHub stars.