Document Backends#
Backends are Docling's format-specific parsing layer. They read raw input files and produce a DoclingDocument directly, without going through the layout-analysis or OCR stages used for PDFs.
There are two distinct backend categories:
DeclarativeDocumentBackend— for structured text formats (CSV, HTML, Markdown, DOCX, XLSX, etc.). These implement a singleconvert() → DoclingDocumentmethod and are driven bySimplePipeline.PaginatedDocumentBackend— for page-based formats (PDF, TIFF, images). These expose apage_count()method and feed into theStandardPdfPipelinefor staged recognition.
All backends are defined under docling/backend/.
Abstract Base Classes#
docling/backend/abstract_backend.py defines the three-level hierarchy:
| Class | Lines | Key contract |
|---|---|---|
AbstractDocumentBackend | 19–51 | is_valid(), supports_pagination(), supported_formats(), unload() |
PaginatedDocumentBackend | 54–63 | Adds page_count() → int |
DeclarativeDocumentBackend | 66–87 | Adds convert() → DoclingDocument; defaults options to DeclarativeBackendOptions |
unload() on the base class closes any open BytesIO stream and sets path_or_stream = None , providing a consistent resource-cleanup contract across all backends.
SimplePipeline Integration#
SimplePipeline is the pipeline that drives all declarative backends. Its _build_document() method:
- Asserts the backend is a
DeclarativeDocumentBackend; raisesRuntimeErrorotherwise . - Calls
conv_res.document = conv_res.input._backend.convert()directly — no page-level loop, no recognition models.
The class method is_backend_supported() enforces this at pipeline-selection time. There is no enrichment or post-processing beyond convert() for declarative formats.
Backend Inventory#
All declarative backends are registered in DocumentConverter._get_default_option() with the corresponding InputFormat and pipeline_cls=SimplePipeline.
| Format(s) | Backend class | Source file |
|---|---|---|
| CSV | CsvDocumentBackend | backend/csv_backend.py |
| HTML | HTMLDocumentBackend | backend/html_backend.py |
| Markdown, TXT, QMD | MarkdownDocumentBackend | backend/md_backend.py |
| DOCX | MsWordDocumentBackend | backend/msword_backend.py |
| XLSX | MsExcelDocumentBackend | backend/msexcel_backend.py |
| PPTX | MsPowerpointDocumentBackend | backend/mspowerpoint_backend.py |
| ODT / ODS / ODP | Odt/Ods/OdpDocumentBackend | backend/opendocument_backend.py |
| EPUB | EpubDocumentBackend | backend/epub_backend.py |
| LaTeX | LatexDocumentBackend | backend/latex/backend.py |
| AsciiDoc | AsciiDocBackend | backend/asciidoc_backend.py |
EmailDocumentBackend | backend/email_backend.py | |
| WebVTT | WebVTTDocumentBackend | backend/webvtt_backend.py |
| Box Note | BoxNoteDocumentBackend | backend/boxnote_backend.py |
| JSON (Docling) | DoclingJSONBackend | backend/json/docling_json_backend.py |
| XML (USPTO / JATS / XBRL / DocLang) | format-specific | backend/xml/ subdirectory |
Paginated backends — DoclingParseDocumentBackend (PDF variants), ImageDocumentBackend, and MetsGbsDocumentBackend — use StandardPdfPipeline instead and are out of scope here.
CSV Backend: Dialect Detection and Table Generation#
CsvDocumentBackend is a representative example of the declarative pattern, illustrating how a backend handles format-specific parsing concerns end-to-end.
Dialect detection (lines 58–73)
csv.Sniffer().sniff(head, ",;\t|:") inspects the first line to auto-detect the delimiter from the set ,, ;, \t, |, :. If sniffing fails (e.g., single-column data with insufficient signal), it falls back to csv.excel (comma-delimited).
Row-uniformity check (lines 95–102)
If rows have different column counts, a warnings.warn() is issued but conversion continues using the max column count for the table dimensions.
Table structure generation (lines 107–129)
Each CSV cell becomes a TableCell with row_span=1, col_span=1 (CSV has no merged cells). The first row is automatically flagged column_header=True . The entire CSV becomes a single TableItem added to the document via doc.add_table(data=table_data) .
The backend does not support pagination (supports_pagination() → False, ) and declares supported_formats() → {InputFormat.CSV} .
Backend Options#
Format-specific options are passed through the backend_options field on each FormatOption subclass and are routed to the backend at instantiation time. All options classes live in docling/datamodel/backend_options.py .
Notable options classes relevant to declarative backends:
| Class | Format | Key fields |
|---|---|---|
HTMLBackendOptions | HTML | render_page, fetch_images, enable_remote_fetch, source_uri |
MarkdownBackendOptions | MD | fetch_images, source_uri |
MsExcelBackendOptions | XLSX | treat_singleton_as_text, parse_charts, gap_tolerance, sheet_names |
EpubBackendOptions | EPUB | fetch_images, max_total_bytes, max_file_bytes |
LatexBackendOptions | LaTeX | parse_timeout, tikz_engine |
The CSV backend exposes no backend_options subclass — its only configurable behavior is the automatic dialect detection at parse time .
See the DocumentConverter Configuration knowledge base article for the full options hierarchy and usage examples.