Skip to main content
pyocr-toolkit logo

pyocr-toolkit

See exactly what text you get out of a PDF or image, and compare how different extraction methods read it.

CI Python License Runs locally

Website · Install · Tours · Providers · CLI · How it works


Compare view, animated: Tesseract OCR scored against an LLM transcription of a scanned document, with the error rate per page and a word-level diff

▶ The website opens with a 24-second video of what it does.


Many GenAI workflows start with "get the text out of this PDF". pyocr-toolkit is a local web app (plus CLI) for checking that step. Upload a document and you get three versions of every page:

Source What it is Good at Weak at
📄 Native text Text already embedded in the file (PyMuPDF) Born-digital PDFs. Exact and instant. Scans have none. Broken font maps produce gibberish.
🔍 Tesseract OCR Classic OCR on the rendered page image Free, local, fast, gives word positions Tables, columns, poor scans, handwriting
✨ LLM transcription A vision LLM told to copy the page verbatim Hard pages, layout, context Costs money. May quietly "fix" or skip text.

Then you can:

  • Extract page by page, a range like 1-5,9, or the whole document, as background jobs
  • Compare any two sources: character and word error rate (CER/WER), word-level diffs, a per-page chart
  • Search across every document and every source at once
  • Export clean text as TXT, Markdown, JSON or JSONL for your pipeline

LLM providers: Claude (Anthropic API), OpenAI, Azure OpenAI, Claude on Azure (Microsoft Foundry), Google Gemini, and any OpenAI-compatible server (Ollama, vLLM, LM Studio, OpenRouter) for local or private models.

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

Tours

Short recordings of the app on demo data (made by .claude/skills/demo/tour_shots.py; each is also in dark mode, as docs/tours/*-dark.webp).

Page inspector: a scanned page has no embedded text, so it's flagged scan; then its OCR and LLM text, all three side by side, and a diff.

Page inspector tour
Compare: Tesseract scored against an LLM across the document, a bar per page, and each page's diff.

Compare tour
Search: every document and every source at once; a hit opens on its page, highlighted on the image.

Search tour
Upload and extract: drop a scan, run Tesseract on every page as a background job, read the result.

Upload and extract tour
Library: how much of each document has native, OCR and LLM text.

Library tour

Install

You need Python 3.10+. Tesseract is optional but recommended (it enables the OCR source).

# Tesseract (optional)
sudo apt-get install tesseract-ocr tesseract-ocr-eng   # Debian / Ubuntu
brew install tesseract                                  # macOS
choco install tesseract                                 # Windows (or the UB Mannheim installer)

Option A: pipx (recommended, installs it as an isolated command):

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

Option B: pip in a virtual environment:

python -m venv .venv && source .venv/bin/activate      # Windows: .venv\Scripts\activate
pip install git+https://github.com/utkarsh5026/pyocr

Option C: Docker (Tesseract and several language packs included):

git clone https://github.com/utkarsh5026/pyocr && cd pyocr
cp .env.example .env            # add your keys
docker compose up -d            # → http://localhost:8000

Run

pyocr init          # writes a .env template in the current folder: add the API keys you have
pyocr doctor        # checks Tesseract, providers and the data folder
pyocr serve --open  # starts the app on http://127.0.0.1:8000 and opens your browser

Everything you upload and extract is stored in ./data (change it with DATA_DIR). The in-app Help page (/help) covers every feature in detail.

The web app

Page What you do there
Home / Drop files to upload; see setup status and recent documents.
Library /documents Document cards showing native / OCR / LLM coverage and how many pages still have no text. Filter by status, workspace or name; delete.
Workspaces /workspaces Named groups of documents. Uploading several files or a .zip offers to create one, with suggested names (from the file names, or adjective-scientist like festive-albattani). Open one to rename it, add files or remove documents.
Overview /documents/{id} Start background extraction (Tesseract or any LLM) for all pages or a range such as 1-5,9; follow progress; see every source (engine + model + prompt) with token usage; export; page thumbnails.
Page inspector /documents/{id}/pages/{n} Page image next to native, OCR and LLM text; run OCR or an LLM on just this page; per-page diff; a Side by side tab with all three texts in synced columns; search hits drawn on the image. Keyboard: ←/→, /, 1-5, t, o.
Full text /documents/{id}/text Read the whole document from one source, optionally beside the page images; find, copy, download.
Compare /documents/{id}/compare Score source B against source A on every page: document-level CER/WER, a clickable CER-per-page chart, and an aligned side-by-side diff of the selected page (opens on the worst page). Works for OCR vs LLM, native vs LLM, or model vs model.
Search /search Search all documents at once.
Jobs /jobs All background extractions, with progress, errors and tokens.
Providers /providers Which settings are set or missing, a form to set keys/endpoints in the browser, plus a Test connection button per provider.
Models /models Search a catalog of vision models rated for transcription (excellent / good / fair / not suitable, with price and reason); list the models your key can use and pick one.
Help /help The full guide: concepts, metrics, workflows, troubleshooting.
API docs /docs Interactive OpenAPI docs for the JSON API.

Configure LLM providers

Paste keys on the Providers page (saved to DATA_DIR/credentials.json, owner-only, applied immediately and taking precedence over the environment), or set them in .env (created by pyocr init) or as environment variables and restart. Keys stay on the server and are never sent to the browser.

Provider Required Optional
Claude (Anthropic API) ANTHROPIC_API_KEY ANTHROPIC_MODEL (default claude-opus-5-5), ANTHROPIC_EFFORT
OpenAI OPENAI_API_KEY OPENAI_MODEL (default gpt-6.2-sol), OPENAI_BASE_URL
Azure OpenAI AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT AZURE_OPENAI_DEPLOYMENT, AZURE_OPENAI_API_VERSION
Claude on Azure (Foundry) ANTHROPIC_FOUNDRY_API_KEY, ANTHROPIC_FOUNDRY_RESOURCE ANTHROPIC_FOUNDRY_MODEL
Google Gemini GEMINI_API_KEY GEMINI_MODEL (default gemini-3.8-flash)
Ollama / vLLM / LM Studio / OpenRouter OPENAI_COMPATIBLE_BASE_URL OPENAI_COMPATIBLE_MODEL, OPENAI_COMPATIBLE_API_KEY

Any model or deployment name can be typed in the UI; the defaults are just starting points. The Models page and the hint under each model box say whether a model suits transcription (custom names are marked as such). The model must accept images. For a fully local setup, run Ollama with a vision model and set OPENAI_COMPATIBLE_BASE_URL=http://localhost:11434/v1.

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            # Tesseract, Markdown to stdout
pyocr extract born-digital.pdf --engine native              # embedded text only, no network
pyocr compare scan.pdf -p openai -m gpt-6.2-sol                   # per-page OCR / native CER vs an LLM
pyocr import a.pdf b.pdf scans.zip folder/ -w invoices      # add many files as one workspace (zips unpacked)
pyocr providers                                             # which providers are ready
python -m pyocr_toolkit --help                              # same CLI without the script on PATH

Documents processed on the command line also appear in the web app's library.

Batch uploads and workspaces

Upload several files, or a .zip, and they land together in a workspace whose name you can edit. pyocr suggests names: the one the files share (invoices-2024.zip → invoices-2024) first, then short adjective-scientist ideas. Zips are unpacked; files that can't be used (unsupported type, zip in a zip, encrypted, broken) are skipped and reported with the reason. A single file still uploads straight to the library. Workspaces only reference documents (data/workspaces/<id>.json), so removing a document from one, or deleting a workspace, keeps the document unless you ask otherwise.

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 no text.
  2. OCR. The page is rendered to pixels (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 (prompts.py). 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 between two texts. CER = edits / reference characters; WER is the same count over words. For example, "the cat sat" → "the bat sat" has 1 edit, so CER = 1/11 = 9%. 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.

The Help page explains each of these in more depth.

Privacy and security

  • Uploads, OCR output and LLM output are stored as plain files under DATA_DIR.
  • A page image is sent to an LLM provider only when you start a transcription, and only to the provider you picked. Native text and Tesseract run entirely locally.

Development

git clone https://github.com/utkarsh5026/pyocr && cd pyocr
pip install -e ".[dev]"
pytest              # LLM providers are tested against mocked HTTP: no keys, no network
ruff check src tests
pyocr serve

Or use the task runner: make lists every developer command grouped by category (make install, make check, make dev for auto-reload, make docker-up, ...). Without make (e.g. on Windows), run python makefile.py <task>.

See CONTRIBUTING.md for the code layout and how to add a provider.

The project website lives in docs/ (plain HTML and CSS, no build step) and is deployed to GitHub Pages by .github/workflows/pages.yml on every push to main that touches it. Its media are made from code, on demo data that needs no API key:

python .claude/skills/demo/tour_shots.py        # docs/tours/*.webp: the app's tours, light and dark (needs Tesseract, Playwright)
cd hero-video && npm install && npm run render  # docs/media/hero-demo.mp4: the website's hero video (Remotion)

License

Apache-2.0. See LICENSE.

Metadata

Release files for pyocr-toolkit 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyocr-toolkit 0.3.0
File Size Uploaded Provenance Actions
pyocr_toolkit-0.3.0.tar.gz 157.0 kB With provenance Details for pyocr_toolkit-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyocr-toolkit 0.3.0
File Interpreter ABI Platform Actions
pyocr_toolkit-0.3.0-py3-none-any.whl Python 3 none any Details for pyocr_toolkit-0.3.0-py3-none-any.whl

Total release size: 306.6 kB

Release files / pyocr_toolkit-0.3.0.tar.gz

Download URL pyocr_toolkit-0.3.0.tar.gz
Size 157.0 kB
Tags Source
SHA-256 checksum
How to use checksums
14ac57aab115a89316a2344f5ee43630eb2d32c3107324a352ff50b2fbffc5bd
BLAKE2b-256 checksum
How to use checksums
0809f38c691b63a4d1059c7cd8530d79c76ad6c52affb246a28a04e1510ed882
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / pyocr_toolkit-0.3.0-py3-none-any.whl

Download URL pyocr_toolkit-0.3.0-py3-none-any.whl
Size 149.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
023d66c4a97cb528973d8f8a47ff9b23592f253754769f87d25f7263b0adf60f
BLAKE2b-256 checksum
How to use checksums
50cb2580e71b27cacb3267d895d5485b1e7ebefc8316ad5dcbbd75f207641e46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for pyocr-toolkit 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyocr_toolkit-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page