Marker PDF to Markdown: Installation, Usage, and When to Use an API Instead
Marker PDF to Markdown: Installation, Usage, and When to Use an API Instead
Marker has become one of the most talked-about open-source tools for converting PDFs into clean, structured Markdown. If you work with scientific papers, technical books, or complex documents and need high-quality output for LLM or RAG workflows, Marker is worth understanding. For simpler document types—or when GPU hardware is unavailable—file2markdown converts PDFs and a dozen other formats to clean Markdown through a browser or REST API with zero infrastructure setup.
What Makes Marker Stand Out
Marker (maintained at github.com/datalab-to/marker) is not a simple text extractor. It runs a pipeline of deep learning models built on the surya OCR engine that:
- Detect layout regions and reading order across multi-column pages
- Identify tables, code blocks, headings, and bulleted lists
- Extract mathematical equations as LaTeX
- Apply OCR only where text extraction fails (scanned pages, embedded images)
This makes it especially strong for academic PDFs—papers with inline math, dense multi-column layouts, and data tables—where simpler extraction tools produce garbled, out-of-order output.
Marker outputs Markdown by default but also supports JSON (structured blocks with bounding-box metadata) and HTML. That flexibility makes it useful both for direct LLM ingestion and for downstream pipelines that need block-level structure for retrieval.
Installing Marker
Marker requires Python 3.10 or later. Install with pip:
pip install marker-pdf
On first run, Marker downloads the surya model weights (roughly 2–4 GB total). Set TORCH_HOME or HF_HOME to control where the weights are cached. To install the full version with all optional dependencies:
pip install marker-pdf[full]
The [full] extra adds support for additional file formats beyond PDFs, OCR language packs, and improved image handling.
Converting a PDF with Marker
CLI — single file:
marker_single input.pdf output_dir/
Marker creates output_dir/input/input.md along with any extracted images saved as separate files. For batch conversion across a folder:
marker /path/to/pdfs/ output_dir/ --workers 4
The --workers flag controls parallel processes; on a multi-GPU machine you can push this higher.
Python API:
from marker.converters.pdf import PdfConverter
from marker.models import create_model_dict
models = create_model_dict()
converter = PdfConverter(artifact_dict=models)
result = converter("research_paper.pdf")
print(result.markdown)
The returned object contains result.markdown (the full document as Markdown), result.metadata (title, language, page count), and optionally rendered images.
Marker's GPU Requirement
Most guides skip this practical detail: Marker is technically CPU-compatible, but CPU conversion is very slow—expect one to five minutes per page on a complex document. Real-world performance by hardware:
- GPU (8–16 GB VRAM): Fast and production-ready. A consumer GPU (RTX 3080 or better) handles most research papers in seconds.
- Apple Silicon (MPS): Supported and reasonably fast—a solid option on M-series Macs for local workflows.
- CPU only: Works for short tests and single-page documents, but impractical for batch processing.
If your pipeline needs to process hundreds of PDFs and you lack GPU infrastructure, the total compute cost of self-hosting Marker frequently exceeds what a hosted API charges per document. That crossover point is worth calculating before committing to the local-model approach.
When Marker Is the Right Choice
Marker wins when:
- Your documents are scientific papers, textbooks, or technical manuals with equations, dense tables, and complex multi-column layouts
- You need local, offline processing for data-privacy reasons or air-gapped environments
- You already run GPU workloads and can amortize the hardware cost
- You want JSON-format output with block-level bounding boxes for chunking Markdown for vector databases
For a side-by-side quality comparison with its closest competitor, see Marker vs Docling and Marker vs MarkItDown.
When to Use a Cloud API Instead
Marker's model-download overhead and GPU dependency make it overkill for a wide range of common scenarios:
Office documents. Word, Excel, and PowerPoint files can be converted to Markdown without deep learning models. The quality difference between Marker and lighter tools is negligible for these formats. For quick conversions, /convert/pdf-to-markdown and /convert/docx-to-markdown require no installation.
Mixed document batches. If your corpus mixes PDFs, DOCX files, spreadsheets, and images, file2markdown handles all formats through a single endpoint—no dependency matrix to manage.
No-GPU environments. Cloud functions, CI pipelines, and serverless runtimes typically lack GPU access. The file2markdown.ai REST API integrates in a few lines and handles OCR server-side, making it a natural fit for these environments.
Rapid prototyping. If you're testing whether Markdown conversion improves RAG retrieval quality, a hosted API lets you validate the hypothesis without spinning up model infrastructure. For a broader look at the Python library ecosystem, automating PDF to Markdown with Python covers your options end to end.
Frequently Asked Questions
Does Marker work without a GPU?
Yes, Marker runs on CPU. However, the surya models powering its layout detection and OCR are computationally intensive, so CPU-only processing can take several minutes per page on complex documents. For anything beyond a short test, a GPU or Apple Silicon (MPS) is strongly recommended.
What file formats does Marker support beyond PDF?
Marker supports PPTX, DOCX, XLSX, HTML, EPUB, and image files (JPG, PNG, TIFF, WebP). Output formats are Markdown, JSON (structured blocks with metadata), and HTML. This breadth makes it more versatile than early versions, which were PDF-only.
Is there a hosted Marker API or online version?
The Marker project is maintained by Datalab (datalab.to), which offers a hosted conversion API. If you need a simpler integration without managing Datalab API keys or want support for formats outside Marker's Python environment, file2markdown.ai provides a REST API that uses server-side OCR across the same document types.
How does Marker compare to Docling and PyMuPDF4LLM?
For scientific PDFs with heavy mathematics and complex layouts, Marker generally matches or exceeds Docling in output quality while being faster on GPU. PyMuPDF4LLM is faster still but is less layout-aware and skips OCR on scanned content. The pymupdf4llm vs Docling post covers the speed-versus-quality tradeoffs in the Python PDF parsing space.
The Markdown Memo
A fortnightly note for lawyers, researchers, accountants, and anyone else drowning in PDFs, scans, and decks. No spam.