# Marker

> Convert PDFs and documents to Markdown, JSON, or HTML with tables and equations intact

- Category: Retrieval & Knowledge (RAG) / Parsing & Ingestion
- Language: Python
- Licence: GPL-3.0
- Repository: https://github.com/datalab-to/marker
- Website: https://www.datalab.to
- Canonical page: https://ai-tldr.dev/tools/marker/

## In short

Marker is Convert PDFs and documents to Markdown, JSON, or HTML with tables and equations intact. It sits in the Parsing & Ingestion category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed GPL-3.0. To get started: install Marker.

## Overview

Marker is a Python document-conversion pipeline that turns PDFs and other files into clean Markdown, JSON, chunks, or HTML. It handles PDF, image, PPTX, DOCX, XLSX, HTML, and EPUB files in any language, and keeps tables, forms, equations, inline math, links, references, and code blocks intact.

It is aimed at developers who need to feed documents into RAG pipelines, search indexes, or LLM applications. By producing structured text that mirrors the original layout, it gives downstream retrieval and chunking steps cleaner input than raw text extraction.

Marker runs on GPU, CPU, or MPS, and works offline by default. For harder documents you can add the optional --use_llm flag to bring in a Gemini or Ollama model, which improves table merging, inline math, and form extraction.

## What it does

- Converts PDF, image, PPTX, DOCX, XLSX, HTML, and EPUB files in all languages
- Outputs Markdown, JSON, chunks, or HTML, with tables, equations, inline math, links, references, and code blocks formatted
- Extracts and saves embedded images, and removes headers, footers, and other artifacts
- Optional hybrid mode (--use_llm) uses a Gemini or Ollama model to boost accuracy on tables, math, and forms
- Structured extraction from a JSON schema (beta)
- Runs on GPU, CPU, or MPS, and is extensible with your own formatting and logic

## Getting started

You need Python 3.10+ and PyTorch installed. Install Marker from PyPI, then convert a file from the command line.

1. Install Marker

   Install the base package for PDFs. Add the [full] extra to convert other document types like DOCX, PPTX, and EPUB.

```bash
pip install marker-pdf
# for non-PDF documents:
pip install marker-pdf[full]
```

2. Convert a single file

   Run marker_single on a PDF or image. The output format and pages can be controlled with flags.

```bash
marker_single /path/to/file.pdf --output_format markdown
```

3. Try the interactive app (optional)

   Marker ships with a Streamlit app for trying conversions with basic options in the browser.

```bash
pip install streamlit streamlit-ace
marker_gui
```

4. Boost accuracy with an LLM (optional)

   Pass --use_llm to merge tables across pages, handle inline math, and extract form values. It defaults to gemini-2.0-flash and can use any Gemini or Ollama model.

```bash
marker_single /path/to/file.pdf --use_llm
```

## When to use it

- Preparing PDFs and office documents as clean Markdown for ingestion into a RAG or search pipeline
- Extracting tables, equations, and inline math from scientific papers and textbooks into structured JSON
- Batch-converting mixed document formats (DOCX, PPTX, XLSX, EPUB) into a single text format for indexing
- Pulling structured fields from forms or documents using a JSON schema (beta)
