Marker: High-Accuracy Document Conversion to Markdown and JSON

Summary
Marker is an open-source Python tool designed for high-accuracy conversion of documents like PDFs, images, and office files into Markdown, JSON, and HTML. It excels at preserving complex formatting, extracting images, and can leverage LLMs for even greater precision. This makes Marker a powerful solution for structured document intelligence.
Repository Info
Introduction
Marker is a powerful, open-source tool developed by datalab-to, designed to convert various document types into structured formats such as Markdown, JSON, chunks, and HTML with high speed and accuracy. It supports a wide range of input files including PDFs, images, PPTX, DOCX, XLSX, HTML, and EPUB, across all languages.
Key features of Marker include:
- Conversion of diverse file types.
- Accurate formatting of tables, forms, equations, inline math, links, references, and code blocks.
- Extraction and saving of images.
- Intelligent removal of headers, footers, and other artifacts.
- Extensibility for custom formatting and logic.
- Structured extraction based on a JSON schema (beta).
- Optional integration with Large Language Models (LLMs) for boosted accuracy.
- Compatibility with GPU, CPU, and MPS for flexible deployment.
Marker has demonstrated favorable performance in benchmarks against leading cloud services like Llamaparse and Mathpix, as well as other open-source tools, offering superior speed and accuracy.
Installation
To get started with Marker, you'll need Python 3.10+ and PyTorch.
Install the core marker-pdf package:
pip install marker-pdf
For converting documents other than PDFs, install additional dependencies:
pip install marker-pdf[full]
Examples
Marker offers various ways to convert documents, from command-line interfaces to a Python API.
Interactive App
Try Marker interactively with a Streamlit app:
pip install streamlit streamlit-ace
marker_gui
Convert a Single File
Convert a PDF or image file from the command line:
marker_single /path/to/file.pdf
You can specify options like --output_format [markdown|json|html|chunks] and --use_llm for enhanced accuracy.
Convert Multiple Files
Process an entire folder of documents:
marker /path/to/input/folder
This command supports all the options available for marker_single.
Use from Python
Integrate Marker directly into your Python applications:
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("FILEPATH")
text, _, images = text_from_rendered(rendered)
Marker also provides specialized converters for specific tasks, such as TableConverter for extracting tables, OCRConverter for OCR-only processing, and ExtractionConverter for structured data extraction using a JSON schema.
Why Use Marker
Marker stands out as a robust solution for document conversion due to several compelling reasons:
- Unmatched Accuracy: Benchmarks show Marker consistently outperforms competitors in overall PDF conversion and table extraction, especially when augmented with LLMs.
- High Performance: It offers impressive throughput, processing documents rapidly on various hardware configurations, including GPUs.
- Versatile Input/Output: Supports a broad spectrum of document formats and provides flexible output options including Markdown, JSON, HTML, and optimized chunks for RAG applications.
- LLM Integration: The
--use_llmflag allows leveraging powerful language models like Gemini, Google Vertex, Ollama, Claude, or OpenAI for superior accuracy in complex scenarios like table merging and form extraction. - Extensible Architecture: Its modular design, based on Providers, Builders, Processors, and Renderers, makes it easy for developers to customize and extend its functionality.
- Commercial Options: For enterprise needs, Datalab offers a hosted API and an on-premise solution with high uptime and competitive pricing.
Links
- GitHub Repository: datalab-to/marker
- Datalab Platform: Datalab Platform
- Discord Community: Discord