kmail.at
contact

elsewhere

EnglishEN
← learning

technologies · difficulty ◆◆

Docling — turn messy documents into clean, AI-ready data

Your documents, ready for the model.

You know the failure. You paste a PDF into a model and it reads a two-column journal article as one long run-on sentence, mangles every table, and quotes the page header as if it were content. Docling is the parsing front-end built to stop that — it turns a messy document into structured, machine-readable data before an LLM ever sees it.

AI-generated draft · reviewed and editedThis text was generated with AI as a first draft, then reviewed and edited by the author, who holds editorial responsibility for it.

2026-08-15 · 13 min read

$ docling
68.9k
GitHub stars

docling-project/docling, Oct 2026

2.139.0
current version

docling on PyPI, Oct 2026

MIT
license

open source

IBM Research
origin

built and maintained by IBM

1.37.0
server version

docling-serve on PyPI; 1.31.0 runs here

What it is

Docling is an open-source Python library that converts unstructured documents into structured, AI-ready data. You hand it a PDF, a scanned document, a Word or PowerPoint file, an image, or a URL, and it parses the content, understands the layout (headings, paragraphs, lists, tables, figures, reading order), optionally runs OCR on scanned pages, and exports a clean representation: Markdown, HTML, or a rich JSON that preserves the document’s structure and metadata.

Why it matters

Raw documents are the weak link in retrieval-augmented generation. An LLM fed a raw PDF often cannot tell a headline from a footer, a table column from a paragraph, or a citation from the main text. Docling exists to solve exactly this "garbage in, garbage out" problem. It is the document-parsing front-end that makes content reliable for downstream AI — clean structure, real tables, reading order preserved, with provenance back to the source page. Feed Docling output to a RAG pipeline and you get usable facts instead of mashed text.

How it fits your stack

You can use Docling three ways, depending on how much you want to run. The Python library gives you the DocumentConverter for batch or single-file work inside a script. The CLI wraps the same pipeline for quick conversions from the terminal. And docling-serve exposes the whole thing as a REST API plus a Gradio demo UI, containerized in a ready-to-run Docker image. The output formats overlap everywhere — Markdown for humans and simple RAG, JSON for pipelines that need the full structure, and HTML when you want to keep the document’s look.

Example

$ docling convert report.pdf --to md --output ./out
2026-10-15 10:36:18,527	INFO	docling.document_converter: Going to convert document batch...
2026-10-15 10:36:18,528	INFO	docling.document_converter: Initializing pipeline for StandardPdfPipeline with options hash f6a5131dec8654f3560a4e61b843cb3a
2026-10-15 10:36:20,460	INFO	docling.pipeline.base_pipeline: Processing document report.pdf
2026-10-15 10:36:23,832	INFO	docling.document_converter: Finished converting document report.pdf in 5.31 sec.

The default conversion: a PDF becomes Markdown. --output takes a directory (not --output-dir), and the file is named after the source — report.md here.

$ docling convert report.pdf note.md --to html --output ./out
2026-10-15 10:36:32,049	INFO	docling.document_converter: Going to convert document batch...
2026-10-15 10:36:32,049	INFO	docling.document_converter: Initializing pipeline for StandardPdfPipeline with options hash f6a5131dec8654f3560a4e61b843cb3a
2026-10-15 10:36:33,985	INFO	docling.pipeline.base_pipeline: Processing document report.pdf
2026-10-15 10:36:37,308	INFO	docling.document_converter: Finished converting document report.pdf in 5.27 sec.
2026-10-15 10:36:37,311	INFO	docling.document_converter: Going to convert document batch...
2026-10-15 10:36:37,311	INFO	docling.document_converter: Initializing pipeline for SimplePipeline with options hash 61f86d865f1d74d1ce82f924b41a027e
2026-10-15 10:36:37,311	INFO	docling.pipeline.base_pipeline: Processing document note.md
2026-10-15 10:36:37,314	INFO	docling.document_converter: Finished converting document note.md in 0.01 sec.

Mixed inputs in one pass: the PDF goes through the PDF pipeline, the Markdown file through the simple pipeline, and both are exported as HTML. The same command also accepts URLs as sources.

$ docling convert scan.pdf --to md --no-ocr
2026-10-15 10:37:59,730	INFO	docling.document_converter: Going to convert document batch...
2026-10-15 10:37:59,730	INFO	docling.document_converter: Initializing pipeline for StandardPdfPipeline with options hash 8b346407cfc7c8093c7a4c5c215412db
2026-10-15 10:38:01,319	INFO	docling.pipeline.base_pipeline: Processing document scan.pdf
2026-10-15 10:38:02,566	INFO	docling.document_converter: Finished converting document scan.pdf in 2.85 sec.
2026-10-15 10:38:02,575	ERROR	docling.cli.main: Markdown export produced empty output for scan.pdf

scan.pdf here is a page that is one big JPEG — no text layer at all. With OCR off there is nothing left to extract: the CLI writes a 0-byte file and says so in the log. The same file with the defaults produced real text: "Quarterly Report Revenue grew in all three regions this quarter... Region Q1 Q2 North 12 15 South 9 11".

$ python -c "from docling.document_converter import DocumentConverter; r = DocumentConverter().convert('report.pdf'); print(r.document.export_to_markdown())"
## Quarterly Report

Revenue grew in all three regions this quarter. The table below summarises the numbers.

| Region   |   Q1 |   Q2 |
|----------|------|------|
| North    |   12 |   15 |
| South    |    9 |   11 |

The same pipeline from Python. The heading, the paragraph and the ruled table all survive as real Markdown — r.document.export_to_markdown(). Tables are objects too: len(r.document.tables) is 1 here, and table.export_to_dataframe(doc=r.document) hands the grid back as a DataFrame.

Common flags

convert <file>
convert a document (default output: Markdown)
--to <fmt>
output format: md (default), json, yaml, html, html_split_page, text, doctags, vtt, doclang, dclx, chunks, latex
--output-dir <dir>
write output files into a directory
--ocr / --no-ocr
OCR for scanned / image-only pages — on by default; --ocr-mode full_page forces it
--table-mode <mode>
table recognition mode: accurate (default) or fast
--layout-engine <engine>
layout model: layout_object_detection (default), docling_layout_default, docling_experimental_table_crops_layout
--from <fmt> / from_formats
input format hints — --from on the CLI, from_formats on the REST API
to_formats
comma-separated output formats via the REST API

History

Origin

Docling was created and is maintained by IBM Research. It grew out of the need to feed real-world enterprise documents into AI pipelines that simply could not cope with raw PDFs — text columns, headers, footers, and tables were destroying retrieval quality. IBM open-sourced it under the MIT license, and it has become one of the fastest-growing tools in the document-intelligence and RAG space, with more than 68,000 GitHub stars (68,914 as of October 2026).

The layout-first insight

The core idea is that document understanding is a layout problem before it is a text problem. Docling treats the page as a set of regions — headings, paragraphs, tables, figures — and reconstructs reading order rather than just dumping characters. That is why its Markdown output is structured: the model knows where a heading ends and a paragraph begins, where a table’s cells are, and which page a given block came from. Provenance is baked in, so every element traces back to source coordinates.

From library to service

As Docling matured it split into a conversion core and a serving layer. The core library does the parsing; docling-serve wraps it in a REST API with sync and async endpoints, a Gradio demo UI, and official Docker images (CPU and CUDA). That made it possible to run document conversion as an internal service that other microservices call over HTTP — no ML knowledge required on the consuming side.

Under the hood

The staged pipeline

Every conversion runs a staged pipeline. First, document loading reads the bytes and detects the file type. Then layout analysis detects blocks and reading order. If the input is scanned or image-only, an OCR stage kicks in (Tesseract, EasyOCR, RapidOCR, or a full-page VLM). Table recognition reconstructs cell structure, optionally in an accurate mode. Optional enrichment stages add code detection, formula/LaTeX extraction, and figure or chart understanding. Finally the pieces assemble into the Document model — a Pydantic tree with methods like export_to_markdown(), export_to_html(), and export_to_dict().

The Document model and provenance

The central object is the Document — a Pydantic model tree. It holds blocks, tables, and reading order, plus provenance that tracks source coordinates for each element. That is what makes Docling output verifiable: you can audit where a given fact came from. Tables are first-class: you can iterate doc.tables and export each one to a Pandas DataFrame via table.export_to_dataframe(), which is gold for feeding analytics or structured databases.

Async serving and scaling

docling-serve runs the pipeline behind REST endpoints. The sync endpoints (/v1/convert/file and /v1/convert/source) return the converted document inline. The async twins (/v1/convert/file/async and /v1/convert/source/async) take the same options, return a task_id instead of a document, and you then poll /v1/status/poll/{task_id}, subscribe to /v1/status/ws/{task_id} over a WebSocket for live updates, and fetch the result from /v1/result/{task_id}. The request body is the library's own option set — to_formats, do_ocr, table_mode, page_range, chunking_options, the enrichment switches. Under the hood the default engine is local (in-process), but you can switch to the rq engine backed by Redis to split the API tier from conversion workers — though without at least one worker running, jobs enqueue and never run.

The same CLI, pointed at a service

docling ships a second subcommand for exactly the setup this page describes: `docling convert-remote` converts through a running docling-serve service instead of loading the models locally. Sources are the same — local files, directories, or http(s) URLs — and results are written to --output in the formats given by --to, identical to `docling convert`; it adds --service-url for the service address. Flags that only make sense locally (device, thread counts, PDF-backend internals, the debug visualizers) are deliberately absent from it, which is a fair signal of what the service honours. On this host the docling-serve container answers at http://localhost:5001, where /health returns {"status":"ok"} and /version reports docling-serve 1.31.0 on docling 2.124.0.

Fun facts

Pros & cons

pros

  • + Layout awareness — detects headings, tables, figures and reading order, not a flat text dump
  • + Multi-format input: PDF, DOCX, XLSX, PPTX, images, HTML, Markdown, and email (.msg)
  • + Rich JSON output preserves blocks, tables, provenance and metadata for RAG pipelines
  • + Real OCR support (Tesseract, EasyOCR, RapidOCR, or VLM) for scanned archives
  • + Self-contained serving: REST API + Gradio UI + official Docker images (CPU and CUDA)
  • + Active and fast-moving — MIT-licensed with frequent releases

cons

  • − Heavy ML dependencies (PyTorch + model weights) for a full install
  • − First boot pre-fetches the model set (~1-2GB) into the artifacts volume — a one-time wait before the API comes up
  • − OCR is opt-in; skipping it on scanned PDFs gives empty output
  • − CUDA Docker images have no "latest" tag — you must pin :main or an explicit version

Takeaways

  1. 1Try it fastest: `pip install docling` in a venv, then `docling convert myfile.pdf`
  2. 2OCR is on by default; `--no-ocr` is what turns a scanned page into an empty file, and `--ocr-mode full_page` forces full-page OCR
  3. 3Export JSON (not just Markdown) when you feed a RAG pipeline — you keep structure, tables and provenance
  4. 4`--table-mode accurate` is already the default — reach for `fast` only when you want the speed
  5. 5Deploy docling-serve via the setup script — it pre-fetches models, works on Linux and macOS, and runs from anywhere
  6. 6Manage the service with `./setup-docling.sh --down` / `--restart` / `--no-browser`
  7. 7Persist the model cache (DOCLING_SERVE_ARTIFACTS_PATH or ~/.cache/docling/models) to avoid re-downloading weights

Related commands

← all learning