pyocr toolkit

Open source · Apache 2.0 · Runs locally

See exactly what text you get
out of a PDF.

Many GenAI pipelines start with “get the text out of this document”. pyocr-toolkit shows you that step page by page: the file's embedded text, Tesseract OCR and a vision LLM's transcription, side by side, with error rates and word-level diffs.

$ pipx install git+https://github.com/utkarsh5026/pyocr
pyocr-toolkit in 24 seconds · click to replay
Page inspector: a scanned page next to its native, OCR and LLM text

Three ways to read a page

Each one fails differently. Seeing them side by side is how you find out which to trust.

Native text

What the file already contains

Text embedded in the PDF, read with PyMuPDF. Exact and instant for born-digital files.

  • Perfect on born-digital PDFs
  • Scans have none; broken font maps give gibberish
Tesseract OCR

Classic OCR on the page image

The page is rendered at 300 DPI and recognised from pixel shapes, with a box for every word.

  • Free, local, fast, word positions
  • Tables, columns, poor scans, handwriting
LLM transcription

A vision model told to copy verbatim

Claude, GPT, Gemini, Azure or a local model reads the image with a strict “don't correct” prompt.

  • Hard pages, layout, context
  • Costs money; may quietly “fix” or skip text

Everything you need to check an extraction step

Page or whole document

Extract one page, a range like 1-5,9, or everything, as a background job with progress and token usage.

Error rates you can trust

Character and word error rate (CER/WER) per page and per document, with a clickable chart that opens on the worst page.

Word-level diffs

See exactly which words one source dropped, added or changed. Works for OCR vs LLM, native vs LLM, or model vs model.

Search everything

Search all documents and every source at once. OCR hits are highlighted right on the page image.

Export for your pipeline

Clean text as TXT, Markdown, JSON or JSONL, ready for RAG and ingestion. From the UI or the CLI.

Local and private

Files stay on your disk. A page image goes to an LLM only when you start a transcription, and only to the provider you pick.

A quick tour

Recordings of the real app on demo documents. The LLM in them is a local stand-in, so they can be remade without an API key.

Compare

Pick a reference (the text you trust more) and a candidate. You get document-level CER and WER, a bar per page coloured by how bad it is, and an aligned diff of the selected page.

Here Tesseract is scored against an LLM's transcription of a scan: it read B1 as Bl and 13:20 as 13220. Page 3 has no LLM text yet, so it isn't scored.

localhost:8000 · Compare
Compare view

Install and run

Python 3.10+. Tesseract is optional but recommended: it enables the OCR source.

A pipx recommended

pipx install git+https://github.com/utkarsh5026/pyocr

B pip in a venv

python -m venv .venv
source .venv/bin/activate
pip install git+https://github.com/utkarsh5026/pyocr

C Docker

git clone https://github.com/utkarsh5026/pyocr
cd pyocr && cp .env.example .env
docker compose up -d
terminal
# write a .env template, then add the API keys you have
$ pyocr init
# check Tesseract, providers and the data folder
$ pyocr doctor
# start the app on http://127.0.0.1:8000
$ pyocr serve --open
or straight from the command line
$ pyocr extract report.pdf --engine llm -p anthropic \
    --pages 1-5 --format jsonl -o report.jsonl
$ pyocr extract scan.tiff --engine ocr --format md
$ pyocr extract born-digital.pdf --engine native
$ pyocr compare scan.pdf -p openai -m gpt-6.2-sol
Installing Tesseract
sudo apt-get install tesseract-ocr tesseract-ocr-eng   # Debian / Ubuntu
brew install tesseract                                  # macOS
choco install tesseract                                 # Windows (or the UB Mannheim installer)

Bring any vision model

Set keys in .env. They stay on the server and are never sent to the browser.

ClaudeAnthropic APIANTHROPIC_API_KEY
OpenAIGPT modelsOPENAI_API_KEY
Azure OpenAIyour deploymentsAZURE_OPENAI_*
Claude on AzureMicrosoft FoundryANTHROPIC_FOUNDRY_*
GeminiGoogleGEMINI_API_KEY
Local / compatibleOllama, vLLM, LM Studio, OpenRouterOPENAI_COMPATIBLE_BASE_URL

Inputs: PDF, XPS, EPUB, CBZ, MOBI, FB2, SVG, PNG, JPEG, TIFF (multi-page), BMP, GIF, WebP and anything else PyMuPDF opens.

How it works

  1. Native text

    A PDF page is a list of drawing instructions (“glyph 37 at (72, 700)”). Born-digital files map each glyph back to a character, so the text can be rebuilt exactly. A scan is only a picture, so it has none.

  2. OCR

    The page is rendered to pixels at 300 DPI and Tesseract recognises characters from their shapes, reporting a box for each word. That is why search can highlight OCR hits on the page.

  3. LLM

    The page image goes to a vision model with a strict “transcribe, don't correct” prompt. It reads in context, so it is strong on hard pages, but it can “fix” typos, which the diff view exposes.

  4. Comparison

    Edit distance is the minimum number of character insertions, deletions and substitutions that turn one text into the other. CER = edits ÷ reference characters; WER is the same count over words.

    referencethe cat sat
    candidatethe bat sat
    1 edit ÷ 11 characters = CER 9.1% · 1 wrong word ÷ 3 = WER 33%

    Whitespace is normalised first, because line breaks aren't reading errors. Disagreement between two engines is not proof of error: compare against a born-digital PDF's native text when you need ground truth.

Stop guessing what your pipeline read.

$ pipx install git+https://github.com/utkarsh5026/pyocr && pyocr serve --open