# Zerox

> OCR any document by passing page images through a vision model to get Markdown

- Category: Retrieval & Knowledge (RAG) / Parsing & Ingestion
- Language: TypeScript
- Repository: https://github.com/getomni-ai/zerox
- Website: https://getomni.ai/ocr-demo
- Canonical page: https://ai-tldr.dev/tools/zerox/

## In short

Zerox is an OCR tool that turns documents into Markdown for AI ingestion. It sits in the Parsing & Ingestion category of the Retrieval & Knowledge (RAG) tools and is open-source, written in TypeScript. To get started: install the package.

## Overview

Zerox is an OCR tool that turns documents into Markdown for AI ingestion. Instead of relying on traditional text-extraction rules, it converts each page of a file (PDF, DOCX, image, and more) into an image, sends that image to a vision model, asks for Markdown, and aggregates the per-page responses into one result.

It is aimed at developers who need to feed documents with awkward layouts, tables, and charts into an LLM pipeline. Because vision models read a page the way a person would, Zerox tends to hold up on content that line-based parsers struggle with.

Within the RAG and retrieval space, Zerox fits the document parsing and ingestion step: it produces the clean Markdown you then chunk, embed, and index. It ships as both a Node package (zerox on npm) and a Python package (py-zerox on PyPI), and supports OpenAI, Azure OpenAI, AWS Bedrock, and Google Gemini, with Vertex AI on the Python side.

## What it does

- Converts PDF, DOCX, and image files into Markdown by sending page images to a vision model
- Works with multiple providers: OpenAI, Azure OpenAI, AWS Bedrock, and Google Gemini (plus Vertex AI in Python)
- maintainFormat option carries a prior page's output into the next request to keep tables and formatting consistent across pages
- Concurrent page processing via the concurrency option, with configurable retries and error modes
- Structured data extraction with a schema, including per-page extraction (Node)
- Image controls like orientation correction, edge trimming, DPI/imageDensity, and page selection

## Getting started

Zerox is available as both a Node and a Python package. The Node quickstart below OCRs a PDF and returns Markdown.

1. Install the package

   Install Zerox from npm. It uses graphicsmagick and ghostscript for the PDF-to-image step; these are usually pulled in automatically, but you may need to install graphicsmagick yourself (for example, apt-get install graphicsmagick on Linux).

```bash
npm install zerox
```

2. OCR a document to Markdown

   Call zerox with a file path (local path or URL) and your provider credentials. The result contains the aggregated Markdown plus per-page content and token usage.

```ts
import { zerox } from "zerox";

const result = await zerox({
  filePath: "https://omni-demo-data.s3.amazonaws.com/test/cs101.pdf",
  credentials: {
    apiKey: process.env.OPENAI_API_KEY,
  },
});
```

3. Tune for tables and multi-page formatting

   If your documents have tables that cross pages, enable maintainFormat so each page is processed with the previous page's Markdown as context. This runs synchronously and is slower, but keeps formatting consistent.

```ts
const result = await zerox({
  filePath: "path/to/file.pdf",
  credentials: { apiKey: process.env.OPENAI_API_KEY },
  maintainFormat: true,
  concurrency: 10,
});
```

## When to use it

- Ingesting scanned or image-heavy PDFs into a RAG pipeline as clean Markdown for chunking and embedding
- Extracting tables and structured data from invoices, receipts, or reports using a schema
- Parsing documents with awkward layouts, charts, or multi-column text that line-based OCR mishandles
- Batch-converting a mix of PDFs, DOCX files, and images into Markdown for an LLM workflow
