PDF to Markdown Online

PDF to Markdown in Python

Four libraries do most of the PDF to Markdown work in Python: Docling, Marker, MarkItDown and PyMuPDF4LLM. We installed all four, ran the same five PDFs through each, and wrote down what came out. Here is working code for each, how fast they were, and how to choose.

The short answer

Docling

bash
pip install docling
python
from pathlib import Path
from docling.document_converter import DocumentConverter

converter = DocumentConverter()
result = converter.convert("report.pdf")
markdown = result.document.export_to_markdown()
Path("report.md").write_text(markdown, encoding="utf-8")

IBM's converter runs layout and table-structure models (PyTorch). In our test it got every table right, including the one in the scanned PDF, and kept lists and two-column reading order. Every heading came out as ##, bold, italic and links were dropped, and formulas were replaced with a formula-not-decoded comment. MIT license. For OCR switches, batch runs and offline models see our Docling PDF to Markdown guide.

Marker

bash
pip install marker-pdf
python
from marker.converters.pdf import PdfConverter
from marker.models import create_model_dict
from marker.output import text_from_rendered

converter = PdfConverter(artifact_dict=create_model_dict())
rendered = converter("report.pdf")
markdown, _, images = text_from_rendered(rendered)

Or from the command line, which writes out/report/report.md:

bash
marker_single report.pdf --output_dir out

Marker 2.2.1 runs its models with ONNX on the CPU, with no PyTorch needed (our environment was about 400 MB). Its OCR was the best in our test: the scanned report came back word for word. Tables and two-column order were right and the running header and footer were removed. Headings were all ##, the bulleted list was merged into one paragraph, links and emphasis were dropped, and code lines became headings.

License: code Apache 2.0; model weights under a modified OpenRAIL-M license, free for research, personal use and startups under $5M in funding or revenue. Larger companies need a commercial license.

MarkItDown

bash
pip install 'markitdown[pdf]'
python
from markitdown import MarkItDown

md = MarkItDown()
result = md.convert("report.pdf")
print(result.text_content)

Microsoft's MarkItDown converts Word, Excel, PowerPoint, HTML and more, and it was the fastest library here. For PDFs it mostly extracts plain text: no headings, bullets lost, two table columns merged into one, sections of the two-column paper out of order (1, 3, 2, 4, 6, 5), and an empty result for the scan. MIT license. There is also a CLI: markitdown report.pdf -o report.md.

PyMuPDF4LLM

bash
pip install pymupdf4llm
python
import pathlib
import pymupdf4llm

markdown = pymupdf4llm.to_markdown("report.pdf")
pathlib.Path("report.md").write_bytes(markdown.encode())

For RAG, ask for one chunk per page, with metadata:

python
import pymupdf4llm

pages = pymupdf4llm.to_markdown("report.pdf", page_chunks=True)
for page in pages:
    print(page["metadata"]["page_number"], len(page["text"]))

Built for LLM pipelines on top of PyMuPDF. It kept the right heading levels (wrapped in bold, as in ## **Revenue by region**), lists, emphasis and tables. Links became plain text and the two-column paper kept its running header and footer. It ran OCR on the scan and got the table shape, with misread numbers ("+12%" became "412%"). PyMuPDF is AGPL-3.0, or a commercial license from Artifex, which matters if you ship it in closed-source software or a hosted service.

Speed

Seconds per file on an Apple M1 laptop (CPU only), after the converter was created. "Setup" is creating the converter, which loads the models, done once per process.

LibrarySetupText guide (2 pp.)Report with tablesScanned pageTwo-column paper (2 pp.)
MarkItDown 0.1.93.00.190.060.01*0.41
PyMuPDF4LLM 2.21.01.690.372.670.50
Marker 2.2.17.02.160.401.040.98
Docling 2.155.08.122.69†2.465.241.86

* MarkItDown returned nothing for the scan, hence the near-zero time. † Docling's first file includes loading models it initializes lazily; later files are much faster.

Output quality

DoclingMarkerMarkItDownPyMuPDF4LLM
Heading levelsAll ##All ##NoneCorrect (bold-wrapped)
Bulleted listYesMerged into paragraphLostYes
Bold / italicNoNoNoYes
LinksNoNoNoNo
TablesCorrectCorrectColumns mergedCorrect
Two-column orderCorrectCorrectWrongCorrect
Running header/footerRemovedRemovedKeptKept
Scanned pageTable right, text garbledPerfectEmptyOCR errors
FormulasDroppedPlain textBroken tablePlain text
LicenseMITApache 2.0 + OpenRAIL-M weightsMITAGPL-3.0 / commercial

No library kept the PDF's links. If you need them, or correct heading levels without bold wrappers, our browser converter kept both on the same files. It can't OCR scans, though. The websites we tested alongside these libraries are covered in best PDF to Markdown converters.

How to choose

  1. Are your PDFs scanned? Use Marker (check the license) or Docling with OCR on.
  2. Will you ship this in a product? Docling and MarkItDown are MIT. PyMuPDF4LLM is AGPL, and Marker's weights have revenue limits.
  3. Do you need heading levels for chunking? PyMuPDF4LLM keeps them; Docling and Marker flatten them to one level.
  4. Throughput? MarkItDown and PyMuPDF4LLM are fastest; Marker is close on text PDFs; Docling is the slowest.

Tested December 2026 with Python 3.12. Every code block on this page was run against our sample PDFs before publishing; download them from the test setup.

Last updated