docTR: Document Text Recognition#

Open-source OCR · Powered by PyTorch

OCR made seamless & accessible to anyone

docTR reads PDFs and images and gives you back every word with its position, organized into lines, blocks, layout regions and tables. Run state-of-the-art models in three lines of Python, fine-tune them on your own documents and ship them anywhere.

$ pip install python-doctr
ocr.py
from doctr.io import DocumentFile
from doctr.models import ocr_predictor

model = ocr_predictor(pretrained=True)
doc = DocumentFile.from_pdf("invoice.pdf")
result = model(doc)

# or export to JSON, Markdown, HTML...
print(result.render())
ACME Office Supplies INVOICE 42 Harbour Road, Hamburg No. 2026-0412 Date: 26/10/2026 …
4 tasksdetection · recognition · layout · tables
20+pretrained architectures
100+built-in vocabularies
6export formats
Apache 2.0free for commercial use

Everything you need to read documents

From a scanned receipt to a hundred-page report: docTR covers the whole pipeline, and every stage can be swapped, tuned or retrained.

Two-stage OCR

A text detection model finds the words, a recognition model reads them. Mix and match 9 detection and 9 recognition architectures.

Running OCR
Layout & tables

Detect titles, paragraphs, figures and tables, and turn tables into a row/column grid that loads straight into pandas.

Layout analysis & tables
Rotated documents

Handle skewed scans, upside-down pages and vertical text with built-in page and word orientation classifiers.

Rotated documents
Export anywhere

Get plain text, JSON, Markdown, AsciiDoc, HTML or hOCR, in a reading order that follows columns, headers and footers.

Exporting results
Train & share

Fine-tune any model on your own data with the reference training scripts, then share it on the Hugging Face Hub.

Training
Production ready

GPU & half precision, torch.compile, ONNX export, Docker images, a CLI and a REST API template.

Deployment

How it works

An OCR predictor chains specialized models. Each stage is a regular PyTorch module you can replace with your own.

Find your way around

Whether you need text out of a PDF in five minutes or want to train a model for a new alphabet, start here.

Quickstart

Install docTR and extract the text of your first document in five minutes.

Quickstart
User guide

Load documents, configure the OCR predictor, navigate and export the results.

User guide
Model zoo

All architectures with their benchmarks, to pick the right speed/accuracy trade-off.

Model zoo
Training

Datasets, data formats, training scripts and how to load your own checkpoints.

Training
Deployment

Speed up inference, export to ONNX, and serve docTR with Docker or a REST API.

Deployment
API reference

Every public class and function, generated from the source code.

API reference

Need help with a complex use case?

docTR was created by Mindee and is developed and maintained by t2k GmbH, who offer custom development, integration and consulting around docTR.

Get support →