
Converting PDFs to Markdown is one of the highest-leverage steps for LLM/RAG use. Clean Markdown preserves headings, tables, lists, and reading order far better than raw PDF text extraction.
Here are the practical options in 2026, ranked by typical use case.
1. Easiest / Lightweight (Born-Digital PDFs)
PyMuPDF4LLM — Fast, CPU-only, minimal dependencies, good structure preservation.
pip install pymupdf4llm
import pymupdf4llm
from pathlib import Path
md = pymupdf4llm.to_markdown("document.pdf")
Path("document.md").write_text(md, encoding="utf-8")
- Supports multi-column layouts, tables → Markdown tables, images (optional extraction).
- Excellent starting point for clean, text-layer PDFs.
- No GPU needed; very fast.
Microsoft MarkItDown — Simple multi-format converter (PDF + Office).
pip install markitdown
markitdown document.pdf -o document.md
Good for quick conversion of mixed office files, but weaker on complex layouts or scans.
2. Highest Quality Open-Source (Recommended Default)
Marker (Datalab) — Currently one of the strongest open-source tools for accuracy + speed.
- Handles PDFs, images, DOCX, PPTX, etc.
- Excellent tables, equations, reading order, and OCR.
- Multiple modes: balanced (best quality, GPU preferred), fast, or pure text-layer.
Typical install/use (check the latest GitHub for exact commands, as it evolves):
pip install marker-pdf # or follow current Datalab instructions
marker_single document.pdf --output_dir ./output
Docling (IBM Research) — Strong alternative, especially for complex layouts and production RAG pipelines. Outputs Markdown, JSON, or structured DoclingDocument. Optional GPU acceleration.
MinerU — Often leads on academic papers and complex tables, though it can drop footnotes in some cases.
Rule of thumb:
- Start with PyMuPDF4LLM for simple/fast needs.
- Switch to Marker or Docling when quality (tables, multi-column, equations, scans) matters.
3. Scanned / Image-Based PDFs
These require OCR + layout understanding:
- Marker or Docling (built-in OCR).
- Specialized OCR tools + conversion.
- Vision-language models: Render PDF pages to images and ask Claude / GPT-4o / Gemini / Qwen-VL to output Markdown (works surprisingly well for moderate page counts).
- Hosted tools with “AI Vision” mode.
4. Zero-Setup Online Tools
Convenient for one-off or non-sensitive files:
- Various dedicated PDF→Markdown converters (search for current ones like MDisBetter, file2markdown, pdfmarkdown.app, etc.).
- Many offer free tiers and automatic OCR.
Caution: Avoid uploading confidential documents.
5. Quick Tips for Best Results
- Born-digital (selectable text) → Prefer geometric/layout-aware tools (PyMuPDF4LLM, Marker, Docling).
- Scanned → Use tools with strong OCR + vision models.
- Always inspect the output for:
- Correct heading hierarchy (
#,##, …) - Tables rendered as proper Markdown tables
- Reading order (especially multi-column pages)
- Equations (LaTeX is ideal)
- For RAG pipelines, tools that detect headings well make chunking much more reliable.
- Batch processing is available in most of the open-source tools.
Quick Decision Guide
| Your Situation | Recommended Tool |
|---|---|
| Simple text PDF, speed matters | PyMuPDF4LLM |
| Best overall quality (OSS) | Marker or Docling |
| Academic papers / heavy math | Marker or MinerU / Mathpix |
| Many Office formats + PDF | MarkItDown or Docling |
| One-off / no install | Hosted converter |
| Sensitive data | Local tools only |