Docling Explained: Extract and Prepare Documents for AI

Docling document processing workflow showing how PDFs, images and tables are converted into structured text, layouts and AI-ready data.

Docling is an open-source document processing toolkit that extracts text, tables and document structure from PDFs, Word files, presentations, spreadsheets and other supported formats. It converts document content into structured representations that can be used by artificial intelligence applications.

Traditional text extraction tools often struggle with scanned pages, complex tables and multi-column layouts. Docling addresses these challenges through document layout analysis, optical character recognition (OCR) and structure-aware parsing.

This guide explains what Docling is, how it works, its key features and how to use it to prepare documents for large language models (LLMs) and retrieval-augmented generation (RAG).

Key Takeaways

  • Docling converts documents into structured, machine-readable content.
  • It supports PDFs, scanned documents, Word files and several other formats.
  • Its capabilities include OCR, layout analysis and table structure recognition.
  • Documents can be exported as Markdown, JSON, HTML and other supported formats.
  • Docling helps prepare document content for AI applications and RAG pipelines.

What Is Docling?

Docling is an open-source toolkit originally developed by IBM Research to simplify document conversion and preparation for AI applications. The project is hosted by the LF AI & Data Foundation, and its codebase is available under the MIT license.

Rather than extracting only raw text, Docling aims to understand how information is organized within a document. It can identify headings, paragraphs, tables, lists and other structural elements, depending on the document format and processing configuration.

The extracted content is organized into a unified representation called DoclingDocument. This representation enables developers to access, export and transform document information for different applications.

For example, a financial report may contain headings, multi-column text and tables. Docling can extract these elements while preserving important structural relationships, making the information easier to process with AI systems.

Docling is not a chatbot or a standalone large language model. It primarily provides the document processing layer that prepares information for downstream AI applications.

How Does Docling Work?

Docling processes documents through conversion pipelines that extract content, recognize structure and organize information into a consistent document representation.

A typical document processing workflow involves the following five stages. The exact operations depend on the input format and selected pipeline.

  1. Document input: Docling receives a supported file, such as a PDF, DOCX document, HTML page or scanned image.
  2. Content extraction: The conversion pipeline identifies and extracts available document content. OCR may be used when text is embedded within images or scanned pages.
  3. Layout and structure recognition: Document processing models identify relevant elements such as headings, paragraphs, tables and reading order where supported.
  4. Structured representation: Extracted information is organized into the DoclingDocument model, preserving relevant document relationships.
  5. Export and preparation: The structured document is exported into a suitable format or divided into chunks for downstream AI processing.
Practical Example

A research paper containing two-column text, section headings and experimental tables can be processed into structured content. Instead of receiving one continuous block of text, developers can work with more meaningful document elements and relationships.

Key Features of Docling

Docling combines several document understanding capabilities that make it useful for extracting and preparing information for AI applications.

1. Multi-Format Document Parsing

Processes different document formats through a consistent conversion interface.

2. PDF Layout Analysis

Identifies document regions, headings, paragraphs and other page elements in complex PDF layouts.

3. Optical Character Recognition

Extracts recognizable text from scanned pages and images using supported OCR engines.

4. Table Structure Recognition

Identifies table cells, rows and columns to preserve relationships between extracted values.

5. Reading-Order Recognition

Helps organize extracted information into a logical sequence, particularly in multi-column documents.

6. Structured Document Output

Organizes document elements into a unified representation for programmatic access and conversion.

7. Document Chunking

Supports splitting structured documents into smaller sections suitable for retrieval workflows.

8. Local Document Processing

Supports local execution, allowing developers to maintain greater control over document processing and sensitive information.

Feature availability and extraction quality depend on the document format, installed Docling version, processing models and pipeline configuration.

Document Formats Supported by Docling

Docling supports a wide range of input formats, enabling developers to prepare information from different document sources using a common processing interface.

Supported Input Formats

Format Common Use
PDF Reports, research papers and technical manuals.
DOCX Word documents and business files.
PPTX Presentations and slide content.
XLSX Spreadsheet content.
HTML Web pages and online documentation.
PNG, JPEG and TIFF Images and scanned documents.
Markdown Structured text and documentation.
AsciiDoc Technical and software documentation.

Supported Output Formats

Output Format Best Suited For
Markdown Readable content and text-based LLM applications.
JSON Structured data access and programmatic processing.
HTML Web-based display and structured document representation.
Plain Text Basic text processing and analysis.

Markdown is convenient for language-based AI tasks, while JSON is more appropriate when an application needs detailed document structure or metadata. HTML or structured JSON may be preferable for complex tables because Markdown cannot preserve every table relationship.

For the full list of available input and output formats, refer to the official Docling supported formats documentation.

How to Use Docling in Python

Developers can install Docling as a Python package and use its DocumentConverter interface to process supported documents.

Step 1: Install Docling

Run the following command in a compatible Python environment, preferably inside a virtual environment.

pip install docling

Step 2: Convert a PDF to Markdown

Create a Python file and place a PDF named sample.pdf in the same working directory.

from docling.document_converter import DocumentConverter

converter = DocumentConverter()

result = converter.convert("sample.pdf")

markdown_content = result.document.export_to_markdown()

print(markdown_content)

This example initializes the document converter, processes the PDF and exports its document representation into Markdown. The resulting text can be inspected, saved or passed to another application.

Step 3: Save the Extracted Content

To save the extracted Markdown into a separate file, add the following code.

from pathlib import Path

Path("output.md").write_text(
    markdown_content,
    encoding="utf-8"
)

Step 4: Export Structured JSON

If your application requires structured document information rather than Markdown, export the document as a dictionary and save it as JSON.

import json

document_data = result.document.export_to_dict()

with open("output.json", "w", encoding="utf-8") as file:
    json.dump(
        document_data,
        file,
        ensure_ascii=False,
        indent=2
    )
Important: Initial processing may require downloading model files and other dependencies. These examples follow Docling’s documented Python interface. Actual extraction results depend on the input document and environment.

How Docling Prepares Documents for AI

AI applications often require information to be organized into meaningful text and structured elements before processing. Raw document extraction may lose important relationships between headings, paragraphs, tables and other content.

Docling helps address this problem by converting documents into structured representations that downstream applications can inspect and transform.

Document Element AI Preparation Benefit
Headings and Sections Provide context and document organization.
Paragraphs Prepare readable content for text analysis.
Tables Preserve important relationships between extracted values.
Scanned Text Make recognized text available for digital processing.
Reading Order Improve the logical sequence of extracted content.

Example of Structured Document Extraction

Consider a PDF report containing the following illustrative financial table.

Quarter Revenue
Q1 $120,000
Q2 $150,000

A simplified Markdown representation of this table could look like the following:

## Quarterly Revenue

| Quarter | Revenue  |
|---------|----------|
| Q1      | $120,000 |
| Q2      | $150,000 |

Preserving the table structure helps downstream AI models associate each revenue value with its corresponding quarter instead of treating the numbers as unrelated text.

This is a simplified illustrative example, not the measured output of an actual Docling conversion.

Using Docling for RAG Applications

Retrieval-augmented generation (RAG) combines information retrieval with language model generation. It enables AI applications to retrieve relevant information from document collections before generating responses.

Docling supports the document preparation stage by extracting structured content and enabling document-aware chunking.

Source Documents

PDFs, reports and business documents

Docling Conversion

Extract text, tables and structure

Document Chunking

Divide content into meaningful sections

Embeddings and Indexing

Prepare searchable document representations

Relevant Information Retrieval

Retrieve content related to a user query

LLM Response Generation

Generate an answer using retrieved context

Docling provides document-aware chunking approaches that can use structural information when splitting content. This can help retain relevant context compared with dividing text solely by character count.

Embedding generation, indexing, retrieval and response generation are separate downstream operations in a typical RAG pipeline. These components work together with generative AI models to support document-based question answering.

Although structured extraction can improve the information available to a RAG system, the quality of its answers also depends on chunking, retrieval accuracy, source quality and language model behavior.

Practical Applications of Docling

Docling is useful whenever document content needs to be extracted, organized and prepared for automated analysis or AI-powered applications.

Application How Docling Helps
Research Papers Extract text, section headings and research tables.
Financial Reports Prepare financial tables and report content for further analysis.
Business Documents Convert policies, manuals and internal documentation into structured content.
Scanned Records Recognize available text using OCR.
AI Knowledge Bases Prepare documents for indexing and retrieval.
Technical Documentation Organize instructions, headings and reference material.

For example, a company could use Docling to process product manuals and support documentation before making the extracted information available to AI virtual assistants that answer customer questions.

Benefits and Limitations of Docling

Docling provides a flexible approach to document preparation, but its extraction capabilities should be evaluated according to the quality and complexity of the source documents.

Benefits Limitations
Open-source codebase with an MIT license. Model licenses and dependencies may have separate requirements.
Supports multiple document formats. Processing capabilities vary by format.
Preserves useful document structure. Complex layouts and tables may produce extraction errors.
Supports scanned document extraction through OCR. OCR accuracy depends on scan quality and language support.
Can run locally. Processing may require considerable memory and computational resources.
Supports AI and RAG document preparation. Requires additional components for complete AI applications.

Developers should validate extracted content against source documents, especially when working with important financial, legal or technical information. For sensitive documents, local processing must be combined with appropriate access controls, storage security and verified network settings.

Frequently Asked Questions

What is Docling?

Docling is an open-source document processing toolkit that extracts text, tables and structural information from supported documents and converts them into formats suitable for downstream AI applications.

Is Docling open source?

Yes. Docling originated at IBM Research and its codebase is available under the MIT license. It is hosted by the LF AI & Data Foundation. Individual models and dependencies may have separate licensing terms.

What document formats does Docling support?

Docling supports formats including PDF, DOCX, PPTX, XLSX, HTML, Markdown, AsciiDoc and several image formats. Available formats and processing capabilities depend on the installed version and configuration.

Can Docling extract tables from PDFs?

Yes. Docling includes table structure recognition capabilities that help identify rows, columns and cells in PDF documents. Extraction accuracy depends on table complexity and document quality.

Does Docling support OCR?

Yes. Docling supports optical character recognition through compatible OCR engines to extract recognizable text from scanned documents and images.

Can Docling convert PDFs into Markdown?

Yes. Developers can convert a PDF using Docling’s DocumentConverter interface and export the resulting document using the export_to_markdown() method.

How is Docling used in RAG applications?

Docling prepares documents for RAG by extracting structured content and supporting document-aware chunking. The prepared content can then be embedded, indexed and retrieved using downstream components.

Can Docling run locally?

Yes. Docling supports local execution. Offline processing may require downloading the necessary models and dependencies beforehand and configuring the pipeline to avoid remote services.

Is Docling a large language model?

No. Docling is a document processing toolkit that can use specialized models for document understanding. Its primary purpose is to extract and prepare information for downstream applications, including those powered by large language models.

Conclusion

Docling simplifies the process of extracting and preparing documents for AI by combining document parsing, OCR, layout analysis and structured content conversion.

Its support for Markdown, JSON and document-aware chunking makes it useful for building document-based AI applications and RAG workflows. By selecting suitable processing configurations and validating extracted information, developers can create more reliable document preparation pipelines.

About the author

Stacey Riley

Stacey Riley is a contributor at AI Genius Works, covering artificial intelligence, intelligent automation, robotic process automation (RPA), enterprise technology, and digital transformation. Her published articles explore practical applications of AI across information technology, banking, insurance, pharmaceutical operations, and business process automation. Her writing focuses on explaining technology concepts through accessible language, practical examples, and real-world business use cases, helping readers understand the opportunities, challenges, and limitations of artificial intelligence and automation.