This page provides quick examples for basic document conversion using the Docling CLI and Python API. Docling simplifies document processing by parsing diverse formats into a unified representation for downstream AI/ML workflows.
The conversion process follows a standard path from input to a structured DoclingDocument object, which can then be serialized into various formats.
Title: Document Conversion Data Flow
Docling converts documents from various formats to a unified DoclingDocument representation, which can be exported to multiple output formats using methods defined in the docling-core and orchestrated by DocumentConverter.
Sources: README.md92-101 docs/index.md21 README.md35-38
The docling CLI provides the fastest way to run conversions without writing code.
| Format | Option | Description |
|---|---|---|
| Markdown | --to md | Human-readable text (default) |
| JSON | --to json | Lossless serialization of Docling Document |
| HTML | --to html | Styled HTML output |
| DocTags | --to doctags | Markup for representing layout characteristics |
| Text | --to text | Plain text without Markdown markers |
Sources: README.md75-88 docs/v2.md14-30
The DocumentConverter class is the primary entry point for the SDK.
Sources: README.md92-98 docs/examples/minimal.py19-30
The convert_all method allows for efficient processing of multiple documents. It returns an iterable of ConversionResult objects. Through the raises_on_error argument, you can control if the conversion should raise exceptions immediately or reflect errors in each file's status.
Sources: docs/v2.md107-140 docs/examples/batch_convert.py158-165
The following diagram illustrates the relationship between key classes in the docling package.
Title: Docling Class Interaction
DocumentConverter: The main orchestrator that manages the conversion process docs/examples/batch_convert.py146ConversionResult: Encapsulates the output of a conversion, including the status and the resulting document docs/examples/batch_convert.py54DoclingDocument: The unified document representation providing export methods like export_to_markdown and save_as_html docs/examples/batch_convert.py65-75ConversionStatus: An Enum representing the state of a conversion (SUCCESS, FAILURE, PARTIAL_SUCCESS) docs/examples/batch_convert.py55-107Sources: docs/examples/batch_convert.py35-40 docs/v2.md143-166
Docling automatically detects formats based on file extensions or MIME types.
| Category | Formats |
|---|---|
| Documents | PDF, DOCX, PPTX, XLSX, HTML, LaTeX, Markdown, EPUB, Plain Text (.txt, .text), ODF (.odt, .ods, .odp), QMD, RMD |
| Images | PNG, JPEG, TIFF, BMP, WEBP |
| Audio/Video | WAV, MP3, MP4, AVI, MOV, MKV, WebM (requires asr extra) |
| Specialized | USPTO, JATS, XBRL, DocLang XML, WebVTT, Box Notes, Email (.eml, .msg) |
Sources: README.md35-39 README.md50-57 docs/v2.md3-6
Pipeline options are format-specific. PDF-related settings are encapsulated in PdfPipelineOptions.
Sources: docs/getting_started/installation.md105-122 docs/v2.md65-91
Docling provides native chunkers like HybridChunker that operate directly on the DoclingDocument to preserve structural hierarchy.
Sources: docs/concepts/chunking.md40-62 docs/examples/hybrid_chunking.ipynb79-110
vlm, asr, or specific OCR engines.Sources: docs/index.md27-34 mkdocs.yml60-66