datalab-to/marker

★ 41,033⑂ 0

Convert PDF to markdown + JSON quickly with high accuracy

About datalab-to/marker

datalab-to/marker is an open-source project on GitHub, mainly written in Python. Convert PDF to markdown + JSON quickly with high accuracy It currently holds 41,033 stars and 0 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the AI Models & LLM Tools board.

GitHub Repository Details

Repository datalab-to/marker · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

README

https://github.com/datalab-to/marker/blob/HEAD/Datalab Logo

Datalab

State of the Art models for Document Intelligence

https://github.com/datalab-to/marker/blob/HEAD/Code License https://github.com/datalab-to/marker/blob/HEAD/Model License https://github.com/datalab-to/marker/blob/HEAD/Discord

https://github.com/datalab-to/marker/blob/HEAD/Homepage https://github.com/datalab-to/marker/blob/HEAD/Docs https://github.com/datalab-to/marker/blob/HEAD/Public Playground


Marker

Marker converts documents to markdown, JSON, chunks, and HTML quickly and accurately.

Try Datalab's Managed Platform

Our managed platform uses Chandra, our latest open source model, and other models — higher accuracy than Marker, with opt-in zero data retention, SOC 2 Type 2, and custom BAAs.

If you have high volume workloads, we offer a batch processing service that has processed 1B+ pages in a day at peak — we manage the infrastructure so your workloads finish on time.

The Datalab API turns documents into verifiable knowledge your agents act on. Every result traces back to its page and position, and one API can parse, extract, fill and edit documents.

Get started with about 5,000 free convert pages every month (work email) — sign up.

Performance

Image from the project README

Marker is built around a simple premise: you shouldn't have to choose between VLM-level accuracy and production throughput, or maintain separate tools for GPU and CPU.

On OmniParseBench (GitHub) — 16,288 pass/fail unit tests across 2,937 pages in 92 languages covering text & reading order (8,499 tests), table cell structure (5,386 tests), and block layout (2,403 tests) — as well as olmOCR-bench, Marker defines the Pareto frontier across every hardware tier:

Which mode should I use?

| Mode | Hardware | Throughput | OmniParseBench | Best for | |---|---|---:|---:|---| | --mode balanced (GPU default) | GPU + CPU | 16.9 pg/s | 80.5 (85.6 olmOCR suites) | Production mixed workloads (born-digital PDFs, tables, math, CJK, and scans) | | --mode vllm | GPU | 4.5 pg/s | 85.9 (83.7 olmOCR-bench) | Maximum accuracy on degraded scans, dense equations, handwriting, & complex tables | | --mode fast (CPU/MPS default) | CPU / MPS only | 23.6 pg/s | 71.0 (71.6 born-digital) | Laptops, CI, serverless/CPU containers, and fast local OCR with zero GPU dependencies | | --mode no_ocr | CPU only | 57.0 pg/s | 40.8 (82.7 digital docs) | Bulk born-digital PDFs when you want layout, reading order, & tables at maximum speed |

Image from the project README

See below for the full OmniParseBench and olmOCR-bench tables, per-suite breakdowns, and instructions on how to run your own benchmarks.

Hybrid Mode

For the highest accuracy, pass the --use_llm flag to use an LLM alongside marker. This will do things like merge tables across pages, handle inline math, format tables properly, and extract values from forms. It works with Gemini, Claude, OpenAI-compatible, Azure, Vertex, OpenRouter, or Ollama models. By default, it uses gemini-3.5-flash. See below for details.

Examples

| PDF | File type | Markdown | JSON | |-----|-----------|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------| | Think Python | Textbook | View | View | | Switch Transformers | arXiv paper | View | View | | Multi-column CNN | arXiv paper | View | View |

Commercial usage

Our code is licensed under Apache 2.0 — free to use, including commercially. Our model weights use a modified AI Pubs Open Rail-M license (free for research, personal use, and startups under $5M funding/revenue). For commercial use of the model weights beyond that, visit our pricing page here.

Community

Discord is where we discuss future development.

Installation

You'll need python 3.10+ and PyTorch.

Install with:

pip install marker-pdf

If you want to use marker on documents other than PDFs, you will need to install additional dependencies with:

pip install marker-pdf[full]

Inference backend prerequisites

Surya auto-spawns the server on first use, and you need vllm (NVIDIA GPU) or llama.cpp (CPU / Apple Silicon):

  brew install llama.cpp     # macOS
  # or grab a release from https://github.com/ggml-org/llama.cpp/releases
  

Usage

First, some configuration:

Interactive Viewer App

Marker includes a built-in interactive web viewer (no extra dependencies required) that lets you drop in PDFs, images, or Office documents and inspect layout blocks, reading order, text lines, stage timings, and rendered Markdown, HTML, Chunks, and JSON page by page across all conversion modes (no_ocr, fast, balanced, vllm). Run it with:

marker_gui --port 8000

Then open http://localhost:8000 in your browser (pass --streamlit if you want the legacy Streamlit UI).

Convert a single file

marker_single /path/to/file.pdf

You can pass in PDFs or images.

Options:

OCR runs through the surya VLM, which is multilingual - see the surya README for details. If you don't need OCR, marker can work with any language.

Convert multiple files

marker /path/to/input/folder

Batch sizing cheat sheet (e.g. 1000 docs)

Use from python

See the PdfConverter class at marker/converters/pdf.py function for additional arguments that can be passed.

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)

rendered will be a pydantic basemodel with different properties depending on the output type requested. With markdown output (default), you'll have the properties markdown, metadata, and images. For json output, you'll have children, block_type, and metadata.

Custom configuration

You can pass configuration using the ConfigParser. To see all available options, do marker_single --help.

from marker.converters.pdf import PdfConverter
from marker.models import create_model_dict
from marker.config.parser import ConfigParser

config = { "output_format": "json", "ADDITIONAL_KEY": "VALUE" } config_parser = ConfigParser(config)

converter = PdfConverter( config=config_parser.generate_config_dict(), artifact_dict=create_model_dict(), processor_list=config_parser.get_processors(), renderer=config_parser.get_renderer(), llm_service=config_parser.get_llm_service() ) rendered = converter("FILEPATH")

Extract blocks

Each document consists of one or more pages. Pages contain blocks, which can themselves contain other blocks. It's possible to programmatically manipulate these blocks.

Here's an example of extracting all forms from a document:

from marker.converters.pdf import PdfConverter
from marker.models import create_model_dict
from marker.schema import BlockTypes

converter = PdfConverter( artifact_dict=create_model_dict(), ) document = converter.build_document("FILEPATH") forms = document.contained_blocks((BlockTypes.Form,))

Look at the processors for more examples of extracting and manipulating blocks.

Other converters

You can also use other converters that define different conversion pipelines:

Extract tables

The TableConverter will only convert and extract tables:

from marker.converters.table import TableConverter
from marker.models import create_model_dict
from marker.output import text_from_rendered

converter = TableConverter( artifact_dict=create_model_dict(), ) rendered = converter("FILEPATH") text, _, images = text_from_rendered(rendered)

This takes all the same configuration as the PdfConverter. You can specify the configuration force_layout_block=Table to avoid layout detection and instead assume every page is a table. Tables are emitted as HTML (

) blocks; output_format=json gives you the table blocks with their page bounding boxes.

You can also run this via the CLI with

marker_single FILENAME --use_llm --force_layout_block Table --converter_cls marker.converters.table.TableConverter --output_format json

OCR Only

If you only want to run OCR, you can also do that through the OCRConverter. Set --keep_chars to keep individual characters and bounding boxes (digital PDFs only - pages that go through the VLM return block-level HTML without character boxes).

from marker.converters.ocr import OCRConverter
from marker.models import create_model_dict

converter = OCRConverter( artifact_dict=create_model_dict(), ) rendered = converter("FILEPATH")

This takes all the same configuration as the PdfConverter.

You can also run this via the CLI with

marker_single FILENAME --converter_cls marker.converters.ocr.OCRConverter

Output Formats

Markdown

Markdown output will include:

HTML

HTML output is similar to markdown output:

JSON

JSON output will be organized in a tree-like structure, with the leaf nodes being blocks. Examples of leaf nodes are a single list item, a paragraph of text, or an image.

The output will be a list, with each list item representing a page. Each page is considered a block in the internal marker schema. There are different types of blocks to represent different elements.

Pages have the keys:

The child blocks have two additional keys: Note that child blocks of pages can have their own children as well (a tree structure).

```json { "id": "/page/10/Page/366", "block_type": "Page", "html": "

GitHub Stars & Activity

41,033Stars
0Forks
0Open issues
PythonLanguage

GitHub Popularity

GitHub stars41,033
Forks0
Open issues0
Primary languagePython
License-
Stars gained today0
Created-
Last pushed-

Trending History

Trending statusnot on today's boards

Related AI Projects

More AI Rankings

AI Homed · AI projects from GitHub Trending, topic pages and search · updated daily · about sitemap · robots