docling

Library

docling-project/docling

Parses documents into AI-ready Markdown, HTML, or JSON for gen AI pipelines.

Overview

Docling parses PDFs, DOCX, PPTX, HTML, images, audio and more into a unified document representation, with advanced PDF understanding of layout, reading order, tables, code and formulas. It exports to Markdown, HTML and lossless JSON, supports OCR for scanned files, and integrates with LangChain, LlamaIndex and other AI frameworks.

README Preview

\n  \n    \n  \n\n\n# Docling\n\n\n  \n\n\n[](https://arxiv.org/abs/2408.09869)\n[](https://docling-project.github.io/docling/)\n[](https://pypi.org/project/docling/)\n[](https://pypi.org/project/docling/)\n[](https://github.com/astral-sh/uv)\n[](https://github.com/astral-sh/ruff)\n[](https://pydantic.dev)\n[](https://pypi.org/project/prek/)\n[](https://opensource.org/licenses/MIT)\n[](https://pepy.tech/projects/docling)\n[](https://apify.com/vancura/docling)\n[](https://app.dosu.dev/097760a8-135e-4789-8234-90c8837d7f1c/ask?utm_source=github)\n[](https://docling.ai/discord)\n[](https://www.bestpractices.dev/projects/10101)\n[](https://lfaidata.foundation/projects/)\n\n## What is Docling ?\n\nDocling simplifies document processing by parsing diverse formats — including advanced PDF understanding — and providing seamless integrations with the generative AI ecosystem.\n\n## Features\n\n- 🗂️ Parsing of [multiple document formats][supported_formats] including PDF, DOCX, PPTX, XLSX, HTML, EPUB, Apple Pages, WAV, MP3, WebVTT, Box Notes, email formats (EML, MSG), images (PNG, TIFF, JPEG, ...), LaTeX, DocLang, plain text, and more\n- 📑 Advanced PDF understanding incl. page layout, reading order, table structure, code, formulas, image classification, and more\n- 🧬 A unified, expressive [DoclingDocument][docling_document] representation format\n- ↪️ Various [export formats][supported_formats] and options, including Markdown, HTML, WebVTT, DocLang, [DocTags](https://arxiv.org/abs/2503.11576) and lossless JSON\n- 📜 Support for several application-specific XML schemas including [DocLang](https://doclang.ai), [USPTO](https://www.uspto.gov/patents) patents, [JATS](https://jats.nlm.nih.gov/) articles, and [XBRL](https://www.xbrl.org/) financial reports.\n- 🔒 Local execution capabilities for sensitive data and air-gapped environments\n- 🤖 Plug-and-play [integrations][integrations] incl. LangChain, LlamaIndex, Crew AI & Haystack for agentic AI\n- 🔍 Extensive OCR support for sca

FAQ (5)

Troubleshooting
Why do transparent PNG images turn solid black in Docling picture enrichment (classifier, description, chart extraction)?

Docling's enrichment models convert RGBA images with PIL's convert("RGB"), which keeps the color stored under the alpha channel (usually black), so transparent areas become black instead of white. This affects document_picture_classifier.py:167, picture_description_base_model.py:106, and inference_engines/vlm/_utils.py:131. Fix: replace convert("RGB") at those three sites with _to_rgb from docling/backend/image_backend.py (added in #4511), which flattens the image onto a white background. As a workaround in your own code, composite RGBA onto white before passing images to the models, e.g. bg = Image.new("RGB", img.size, (255,255,255)); bg.paste(img, mask=img.split()[3]). Note page images already go through _to_rgb; only pictures embedded in DOCX/HTML/PPTX via prepare_element hit the buggy path.

GitHub Issue #4774
Troubleshooting
Why does Docling hang forever converting PDFs with thousands of small shapes, ignoring document_timeout?

This is a regression in Docling 2.132–2.134 (commit 42de1e2): the reading order model generates an unbounded number of page-separator candidates (e.g. ~195K for a concert-hall floor plan where each seat is a square), and the candidate merge is quadratic, so conversion effectively never finishes. The document_timeout budget was also not checked inside this phase, so the pipeline blocked forever.

Fix: upgrade to a Docling version including PR #4633. The fix (1) caps separator candidates at 5,000 per page — pages above the cap skip separator extraction with a warning and fall back to default reading order — and (2) the candidate loop and merge now abort when the remaining document_timeout budget is exhausted, recording a TIMEOUT error so conversion returns with status PARTIAL_SUCCESS instead of hanging.

Workaround if you cannot upgrade: pin to the last unaffected version with pip install docling==2.124.

GitHub Issue #4632
Troubleshooting
How to fix Docling segmentation fault (SIGSEGV) when running tesserocr OCR on multiple PDFs in parallel?

Root cause: Docling's TesseractOcrModel caches one tesserocr PyTessBaseAPI reader per pipeline, and tesserocr is not thread-safe. When conversions run concurrently (settings.perf.doc_batch_concurrency > 1, or one DocumentConverter called from several threads), simultaneous SetImage/SetRectangle/GetUTF8Text calls corrupt each other's state. The process then dies with SIGSEGV (exit code 139), raises cysignals.signals.SignalError: Segmentation fault, or silently returns status success with OCR text missing.

Workarounds:

1. Force sequential batch conversion before converting:

from docling.datamodel.settings import settings
settings.perf.doc_batch_concurrency = 1

2. If you call Docling from your own threads, do not share one DocumentConverter. Either create a separate DocumentConverter per thread (each builds its own pipeline and tesserocr readers), or serialize all convert()/convert_all() calls with a threading.Lock.

3. Upgrade docling to the latest release and check issue #4940 for the upstream fix status.

Note: Python cannot catch the SIGSEGV, so one crashing document kills every conversion in the process — keep concurrency at 1 until a thread-safe fix is released.

GitHub Issue #4940
Troubleshooting
How to install Docling with Pillow 13 despite the pillow<13 dependency conflict?

Docling (up to 2.141.0) pins pillow>=10.0.0,<13.0.0 in four packages: docling-slim, docling-core, docling-parse, and docling-ibm-models. This blocks Pillow 13.0.0, which fixes 8 CVEs flagged by pip-audit (CVE-2026-112895, CVE-2026-112400, CVE-2026-112397, CVE-2026-112896, CVE-2026-112897, CVE-2026-112395, CVE-2026-112404, CVE-2026-112899).

Workaround: force Pillow 13 with a dependency override. With uv, add an override to your project or use an overrides file:

uv pip install docling --overrides overrides.txt   # overrides.txt contains: pillow==13.0.0

or in pyproject.toml:
[tool.uv]
override-dependencies = ["pillow>=13.0.0"]

Compatibility was verified with docling 2.132.0 on Python 3.12: PDFs, scanned PDFs, PNGs, and JPEGs all converted successfully, with Markdown exports, page/table counts, and page-image sizes identical to Pillow 12.3.0. TableFormer worked normally. A source audit confirmed docling, docling-core, docling-parse, and docling-ibm-models do not use any APIs removed in Pillow 13 (Image._show, get_child_images, ImageCmsProfile.product_name/product_info, ExifTags.IFD.Makernote, dtype-changing fromarray). A request to raise the cap to <14.0.0 is pending; check releases after 2.141.0 for an official fix.

GitHub Issue #4926
Troubleshooting
Why does Docling split a semicolon-separated CSV file on commas, and how to fix it?

This is a bug in Docling's CSV backend: _sniff_dialect() in docling/backend/csv_backend.py detects the delimiter from the first line (header) only. If a header column name contains a comma (e.g., Weight (kg, net)), Python's csv.Sniffer picks , instead of ;, corrupting every cell. This commonly affects files Excel exports in European locales where ; is the column separator and , is the decimal mark. Workarounds: (1) Remove commas from header column names before converting (e.g., rename Weight (kg, net) to Weight (kg net)) — the same file is then split correctly on ;. (2) Pre-process the file: sniff the dialect using the full file content (csv.Sniffer().sniff(full_text, ',;\t|:')) and rewrite it, or convert the CSV to XLSX first and convert that with Docling. (3) Update Docling once the linked fix PR for issue #4895 is merged, which makes dialect detection use multiple rows for consistency.

GitHub Issue #4895