Docling vs Marker vs Unstructured in 2026: Build a Reliable PDF-to-RAG Ingestion Pipeline
A PDF is not a text file. It is a layout: columns, captions, footnotes, tables, page headers, scanned images, equations and reading order all matter. If your ingestion pipeline flattens those structures into one long string, your RAG system can retrieve the wrong paragraph, detach a number from its table heading, or cite a page that no longer contains the answer.
That is why choosing a document parser is an architecture decision, not a pip-install decision. In this guide, we compare Docling, Marker and Unstructured as document-understanding components, then build a repeatable evaluation and ingestion workflow that keeps page-level provenance intact.
Who this guide is for
This deep-dive is for Python developers, AI platform engineers and teams building private document search, enterprise RAG, contract analysis, research assistants or document automation. It assumes basic Python, virtual environments, PDF handling and familiarity with embeddings or vector search.
You do not need a vector database to follow the parser comparison. The first goal is to turn source files into trustworthy structured records. Chunking, embeddings and retrieval come later.
The short answer
| Choose | When it fits best | What to watch |
|---|---|---|
| Docling | You want a rich, unified document representation, layout-aware conversion, structured exports and a path into structure-aware chunking. | Model artifacts, first-run downloads, hardware requirements and the need to configure optional enrichment stages. |
| Marker | Your workload is PDF-heavy and you want practical conversion modes, Markdown/JSON/HTML/chunk output and an inspectable local conversion workflow. | Its model-weight license is not the same as its Apache-licensed code; check the exact terms before commercial deployment. |
| Unstructured | You ingest many file types and want typed elements, metadata and selectable partitioning strategies in a broader ETL-style pipeline. | PDF strategy selection and local inference dependencies need deliberate configuration; output quality varies by document class. |
There is no universal winner. A clean born-digital PDF, a scanned multilingual form and a 40-page report with nested tables are different workloads. Choose with a representative test set, not a single attractive demo.
Version snapshot: 24 November 2026
- Docling 2.152.0: the project release page lists this version as released on 23 November 2026. Its notes include PDF conversion cancellation, service pipeline selection, multilingual heading-hierarchy improvements and other format fixes. See the official release.
- Marker 2.2.0: released on 12 November 2026. The release describes four conversion modes, an in-process Indra ONNX engine and a new interactive viewer. See the official release notes.
- Unstructured 0.27.37: the repository release page lists 0.27.37 as its latest release in this snapshot, with fixes including vector-heavy PDF extraction and language handling. See the official release.
Pin versions in your own environment and re-check the official release pages before upgrading. The snapshot above is a date-specific reference, not a promise that these versions will remain latest.
What each parser actually returns
1. Docling: a unified document model
Docling converts supported inputs into a structured DoclingDocument rather than treating Markdown as the only useful result. Its Python entry point is DocumentConverter. A ConversionResult exposes the document and conversion metadata, and the document can be exported to Markdown or a structured dictionary. The PDF pipeline can enable OCR and table-structure recognition, and optional stages can enrich formulas, code, pictures or headings.
This model is useful when downstream code needs more than text: section hierarchy, page provenance, tables, images and document structure. Docling also has structure-aware chunking components, so it can be a convenient starting point when you want parsing and chunking to share a document representation.
Official references: DocumentConverter API, supported formats, advanced options and chunking.
2. Marker: a conversion-focused PDF pipeline
Marker converts documents into Markdown, JSON, HTML and chunk-oriented outputs. Version 2.2.0 makes the speed-versus-quality choice explicit: no-OCR and fast paths use lightweight local processing, balanced mode routes more difficult pages through its Surya vision-language model, and vLLM mode uses the full-page VLM path. The project documents CPU, Apple MPS and NVIDIA GPU paths, with different inference backends depending on hardware.
The interactive viewer is especially useful during evaluation because it lets an engineer inspect page layout, reading order, text lines, timings and output representations. That makes it easier to diagnose why a page was parsed incorrectly instead of judging only the final Markdown.
Start with the official Marker repository, its 2.2.0 release and the PyPI package page.
3. Unstructured: typed elements and partitioning strategies
Unstructured is broader than a PDF converter. Its partitioning layer turns documents into typed elements such as titles, narrative text, list items and tables. It supports many formats, and PDF processing exposes strategy choices: fast for extracting an existing text layer, hi_res for layout-aware processing, ocr_only for OCR-first extraction, and auto for selecting a path based on the input and requested options.
For PDFs, the documented auto behavior is important: when table structure inference is requested, the library selects hi_res because that is the strategy that supports PDF table extraction. Otherwise it can choose fast for extractable text or OCR-only for image-based content. A missing local inference dependency can change or break the path you expected, so test the actual environment rather than assuming that installing the base package enables every strategy.
Official references: partitioning and PDF strategies, strategy guidance, chunking and the source repository.
Architecture comparison
| Dimension | Docling | Marker | Unstructured |
|---|---|---|---|
| Core abstraction | Unified DoclingDocument | Conversion pipeline with multiple renderers and block-oriented outputs | Typed element sequence with metadata |
| PDF strategy | Configurable PDF pipeline with OCR, layout and table stages | no_ocr, fast, balanced and vLLM modes | auto, fast, hi_res and ocr_only |
| Output choices | Markdown, JSON/dictionary, HTML and other supported exports | Markdown, JSON, HTML and chunks | Typed elements, HTML/table metadata and chunked elements |
| Best evaluation question | Did the unified structure preserve hierarchy and provenance? | Which conversion mode gives the right quality/throughput trade-off on this hardware? | Did the selected partition strategy produce the right element types and metadata? |
| License check | Codebase is MIT; check each model's original license | Code is Apache 2.0; model weights have separate modified OpenRAIL-M terms | Repository declares Apache 2.0; review dependency and model licenses for your deployment |
Do not treat the output formats as interchangeable. A Markdown string is convenient for humans, but a production pipeline should preserve structured elements and source coordinates before it creates chunks.
Build a fair parser evaluation: the numbered walkthrough
Step 1 — Create a small but representative document corpus
Start with 20–50 documents if you are building an initial decision set. Include several examples of each class you expect in production:
- Born-digital PDFs with selectable text.
- Scanned PDFs with skew, low contrast or stamps.
- Two-column papers and reports.
- Tables that span pages, contain merged cells or have footnotes.
- Forms, invoices and documents with checkboxes or key-value fields.
- Equations, code blocks, charts and captions.
- Non-English pages and mixed-language documents.
- Very long files, malformed files and encrypted or password-protected PDFs.
For each test file, record the expected page count, language, important headings, selected table cells, a few exact text passages and the page where each passage appears. This becomes your gold set. Keep the original files immutable and store a checksum with each fixture.
Step 2 — Isolate the environments
These packages have different dependency trees and optional inference components. Use separate virtual environments or containers so that one parser's dependency upgrades do not silently change another parser's behavior.
python -m venv .venv-docling
# Activate the environment, then:
python -m pip install --upgrade pip
python -m pip install "docling==2.152.0"
python -m venv .venv-marker
# Activate the environment, then:
python -m pip install --upgrade pip
python -m pip install "marker-pdf==2.2.0"
python -m venv .venv-unstructured
# Activate the environment, then:
python -m pip install --upgrade pip
python -m pip install "unstructured[pdf]==0.27.37"
Unstructured's local high-resolution path can require additional local-inference and system dependencies. Marker may need its documented inference backend for balanced or VLM modes. Read each version's installation instructions before adding extras. Do not assume that a successful import means OCR or layout inference is ready.
Check Python compatibility before building a single shared image. The current Unstructured package metadata declares Python 3.11 through 3.13, while Docling and Marker document their own supported ranges. A separate environment avoids turning a parser comparison into a dependency-resolution contest.
Step 3 — Run Docling with explicit PDF options
Do not leave important options implicit during evaluation. This example enables OCR and table structure and writes both Markdown and a structured export:
from pathlib import Path
import json
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import PdfPipelineOptions
from docling.document_converter import DocumentConverter, PdfFormatOption
options = PdfPipelineOptions()
options.do_ocr = True
options.do_table_structure = True
converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(
pipeline_options=options
)
}
)
result = converter.convert("fixtures/annual-report.pdf")
print("status:", result.status)
document = result.document
Path("out").mkdir(exist_ok=True)
Path("out/annual-report.md").write_text(
document.export_to_markdown(),
encoding="utf-8",
)
Path("out/annual-report.json").write_text(
json.dumps(document.export_to_dict(), ensure_ascii=False, indent=2),
encoding="utf-8",
)
For born-digital PDFs, test a second profile with OCR disabled if the text layer is trustworthy. For difficult tables, compare the fast and accurate table modes supported by your installed version. Save the options alongside the output so that a later rerun is reproducible.
Step 4 — Run Marker in more than one mode
Marker's mode is part of the experiment, not a cosmetic flag. Start with the documented single-file command and inspect the available options for the exact installed release:
marker_single fixtures/annual-report.pdf --mode fast
marker_single fixtures/annual-report.pdf --mode balanced
marker_single --help
Use fast as a lower-cost baseline on CPU or Apple MPS, and balanced when the workload includes complex tables, math, non-Latin scripts or scans and you have the required inference backend. Test vLLM mode only when the full-page VLM path is justified by your quality requirements and hardware. Do not compare one parser's best mode with another parser's cheapest mode and call the result a fair benchmark.
Open the generated output in Marker’s viewer where available. Inspect the page overlays and reading order on the exact pages that failed your gold-set checks.
Step 5 — Run Unstructured with an intentional strategy
For a born-digital PDF with a clean text layer, start with fast. For a document where layout and table classification matter, test hi_res and request table inference. For a scanned document, test ocr_only or auto and confirm that the required OCR language packs are installed.
from unstructured.partition.pdf import partition_pdf
elements = partition_pdf(
filename="fixtures/annual-report.pdf",
strategy="hi_res",
infer_table_structure=True,
languages=["eng"],
)
for element in elements[:10]:
metadata = element.metadata.to_dict()
print({
"category": element.category,
"text": str(element)[:180],
"page": metadata.get("page_number"),
"table_html": metadata.get("text_as_html"),
})
For a simple digital PDF, repeat the run with strategy set to fast. Record the strategy, installed extras, OCR languages and inference configuration. If the result silently falls back or a strategy is unavailable, that is a deployment finding—not a reason to hide the configuration.
Step 6 — Normalize results into your own schema
Do not let the vector database schema become a mirror of whichever parser you selected first. Define an internal representation that is stable even if you replace the parser later.
from dataclasses import dataclass
from typing import Optional
@dataclass
class ParsedBlock:
document_id: str
text: str
kind: str
page_number: Optional[int]
heading_path: list[str]
source_file: str
table_html: Optional[str] = None
parser_name: str = ""
parser_version: str = ""
extraction_run_id: str = ""
Build a small adapter for each parser. For Docling, start from the documented structured document export and traverse its document items and provenance. For Marker, consume the JSON/block output when coordinates and element types matter; use Markdown as a readable export, not your only database record. For Unstructured, map each element's category, text and metadata into the common schema. Keep the original metadata payload in object storage if you may need fields your normalized schema does not yet model.
At minimum, preserve document ID, original filename, page number, element type, heading path, parser name/version, extraction options, source coordinates when available and a stable extraction-run ID. Do not invent a page number when the parser did not provide one.
Step 7 — Keep tables and figures structurally intact
A table is not just a paragraph containing numbers. Store its caption, page, column headers and row relationships. If you convert it to Markdown or HTML, keep that representation and a structured form where possible. When a table is too large for one chunk, split by row groups and repeat the header context rather than slicing arbitrary characters through a cell.
For figures, keep the image or a durable object-storage reference, its caption and its page provenance together. If you later generate a model-written image description, label it as generated metadata. Do not mix it with text that was actually printed in the source document.
Step 8 — Chunk only after validating the parsed structure
Parsing and chunking solve different problems. First verify that the parser found the right title, section, table and page. Then create retrieval chunks. A structure-aware chunker should prefer section boundaries, preserve heading paths and avoid separating a table from its header.
Docling provides HybridChunker and hierarchical chunking options. Unstructured offers basic and by-title chunking, with controls for maximum and soft chunk sizes. Marker can export chunk-oriented output. For a fair comparison, normalize the parser output and run the same downstream chunking policy over each result. Otherwise you are comparing parser quality and chunker behavior at the same time.
For an existing end-to-end local RAG example, see Build a Private Document Q&A Assistant with Ollama and Python. This article focuses on the parsing and structure-preservation layer that should come before that retrieval workflow.
Step 9 — Evaluate parsing separately from retrieval
Use a scorecard that reflects your documents. Useful measures include:
- Text coverage: expected text found, missing text and duplicated text.
- OCR quality: character or word error rate against a human-checked transcription for scanned pages.
- Reading order: whether paragraphs and columns appear in the expected sequence.
- Table fidelity: exact cell values, row/column alignment, header association and merged-cell behavior.
- Structure: heading detection, list boundaries, caption association and element classification.
- Provenance: whether each returned passage points to the correct source file and page.
- Operations: cold start, warm throughput, peak memory, CPU/GPU use, failure rate and timeouts on your hardware.
Do not collapse every measure into one score too early. A parser that is excellent on clean text but poor on invoices may still be the right choice for a research-paper corpus. Report results by document class and retain the failed examples.
Only after parsing is stable should you run retrieval evaluation. The GyanAangan guide Ragas vs DeepEval vs Phoenix with Local Ollama Judges covers the separate evaluation layer for retrieval and generated answers.
Step 10 — Add a production ingestion boundary
A practical pipeline looks like this:
- Accept the upload into private quarantine storage.
- Validate file signature, extension, size, page count and allowed format.
- Calculate a content hash and create an idempotent ingestion job.
- Run the parser in an isolated worker with CPU, memory, disk and wall-clock limits.
- Normalize the output and validate page counts, text coverage and required metadata.
- Route low-confidence or failed pages to a review queue rather than silently indexing them.
- Store the original file, normalized JSON, rendered assets and parser configuration under the same document ID.
- Chunk, embed and index only validated records.
- Publish an ingestion status and keep a rollback path for reprocessing.
Store parser name, version, configuration and model identifiers with every run. When a parser upgrade changes output, you need to know which documents require reprocessing. A checksum prevents duplicate uploads from creating duplicate chunks, while an extraction-run ID lets you compare old and new outputs without losing the source.
Step 11 — Use a routing policy instead of forcing one parser everywhere
After you have measured your own corpus, a hybrid policy may be simpler than choosing one winner. For example:
def choose_parser(document):
if document.is_scanned or document.has_complex_tables:
return "docling_or_marker_balanced"
if document.is_clean_text_pdf:
return "unstructured_fast_or_marker_fast"
if document.has_many_office_formats:
return "docling_or_unstructured"
return "review_or_default_parser"
This is an illustrative policy, not a detector you can deploy unchanged. Replace the booleans with signals from your file inspection and evaluation set. Keep routing deterministic and log why each document took a path. If a document is high-risk or its parser confidence is low, ask for human review instead of quietly sending uncertain text into a model.
Trade-offs that matter in production
Quality is document-dependent
No parser guarantees perfect OCR, table reconstruction or reading order. A scanned page with handwriting, a rotated invoice and a clean research paper stress different components. A benchmark score from a project's own release is useful context, but it is not a substitute for your documents, hardware and evaluation protocol.
Hardware and cold-start behavior change the economics
OCR and layout models can make the first conversion expensive in memory and startup time. Marker 2.2.0's mode design makes hardware-specific paths more explicit. Docling exposes accelerator and pipeline options. Unstructured's hi_res route has different dependencies from its fast path. Measure both cold and warm runs, and include model download/cache size in deployment planning.
Output format is an interface contract
Markdown is portable but can lose relationships that structured JSON or typed elements retain. If your application needs citations, table answers or page previews, define those requirements before you settle on a parser. Keep the raw parser output so you can improve the adapter later without reparsing every source file.
Licenses apply to more than the Python package
Docling's codebase is MIT-licensed, but its project notes that individual models retain their own licenses. Unstructured's repository declares Apache 2.0. Marker states that its code is Apache 2.0 while its model weights use modified OpenRAIL-M terms with usage restrictions. Read the current license files for the exact model artifacts you deploy, especially for a commercial service or redistribution.
Security and privacy checklist
- Treat every upload as untrusted. Validate actual file type, enforce size and page limits, and reject unexpected archive or embedded content.
- Isolate parser workers. Use a non-root account, read-only application filesystem, temporary per-job storage, network restrictions and hard resource limits.
- Prevent SSRF. Do not pass user-controlled URLs directly to a parser that can fetch remote sources. Fetch through a controlled service with host allowlists and private-address blocking.
- Protect extracted data. Store originals and parsed text outside public web roots, encrypt storage and transport, and apply tenant-level access checks to every derived chunk.
- Keep document text untrusted. A PDF can contain instructions that look like prompts. Retrieved text must never override system policy or grant an agent permission to call tools.
- Control model and telemetry egress. Confirm whether OCR, VLM or enrichment stages call remote services. A locally installed package does not automatically mean the entire pipeline is offline.
- Review retention and licensing. Set deletion policies for originals, page images, OCR outputs, logs and model caches. Check model-weight and dependency licenses before commercial use.
The OWASP File Upload Cheat Sheet is a useful baseline for upload validation, storage, scanning and parser hardening.
Troubleshooting common failures
| Symptom | Likely cause | What to check |
|---|---|---|
| Scanned PDF returns almost no text | OCR is disabled, unavailable or missing the document language. | Enable the parser's OCR path, install the required language data and test one page before rerunning the batch. |
| Two-column pages are interleaved | Reading-order or layout detection is wrong for that page. | Inspect page overlays or element coordinates; compare another mode and keep the original page image for review. |
| Tables become a stream of numbers | Table structure inference was not enabled or the page was routed through a text-only strategy. | Use a table-aware path, retain HTML or structured table output and verify cell boundaries against the source. |
| Marker balanced mode cannot start | The required local inference backend or container/GPU runtime is missing. | Check the v2.2.0 install notes, Docker/NVIDIA setup or llama.cpp backend, then run a small fixture. |
| Unstructured hi_res falls back or errors | Local inference dependencies are absent or incompatible. | Check the installed extras, Detectron2-related requirements, OCR installation and the actual strategy reported by the run. |
| Output changes after an upgrade | Parser, model or default options changed. | Pin versions and model artifacts, keep golden fixtures and compare outputs before promoting the upgrade. |
| Chunks have no useful citations | Page and coordinate metadata were dropped during normalization or chunking. | Carry provenance through every transformation and test that a retrieved chunk resolves to its original page. |
Frequently asked questions
Is Docling better than Marker for RAG?
Not for every corpus. Docling is attractive when you want a unified structured document model and integrated structure-aware chunking. Marker is attractive for PDF-focused conversion and explicit hardware-dependent modes. Compare both on the same documents and preserve the output features your retrieval layer needs.
Is Unstructured only for PDFs?
No. Its partitioning library supports many document types, including Office files, email, HTML, images and PDFs. That breadth can be valuable when one ingestion service must normalize heterogeneous sources.
Can I use all three locally?
Yes, the projects document local workflows, but local execution still requires model files, OCR engines, inference backends and compatible hardware for some modes. Verify that no remote service is enabled and monitor network egress if offline processing is a requirement.
Should I convert every PDF to Markdown before embedding?
Markdown is a useful export, but do not make it your only source of truth if you need table structure, page-level citations, coordinates or figure relationships. Keep structured parser output and create Markdown or chunks as derived views.
Can a parser guarantee correct table extraction?
No. Table structure models can misread merged cells, multi-page tables, tiny text and complex layouts. Validate important cells against a human-checked set, and route low-confidence financial or legal documents to review.
Which one is cheapest?
There is no reliable universal cost ranking. Your total cost includes CPU/GPU time, model storage, cold starts, engineering work, failure recovery and any hosted processing. Measure cost per accepted page on your own corpus rather than comparing marketing throughput figures.
Does local parsing make the whole RAG system private?
No. Embeddings, rerankers, LLM calls, logs, telemetry, backups and user interfaces can still send or expose data. Audit the full data path, not only the PDF parser.
Recommended reading on GyanAangan
- Build a Private Document Q&A Assistant with Ollama and Python — the end-to-end local RAG workflow that consumes parsed documents.
- Production RAG Engineering in 2026 — retrieval, reranking, grounded answers and observability after ingestion.
- Incremental Local RAG with Ollama and SQLite — avoid re-embedding unchanged source documents.
- RAG Evaluation: Ragas vs DeepEval vs Phoenix — evaluate retrieval and answer quality after your parser has passed its own tests.
Primary sources and further documentation
- Docling v2.152.0 release notes, repository and license, Python DocumentConverter reference, advanced PDF options and chunking guide.
- Marker v2.2.0 release notes, repository and installation guide, model license and PyPI package metadata.
- Unstructured 0.27.37 release, PDF partitioning reference, strategy guide and chunking guide.
- OWASP File Upload Cheat Sheet for safe handling of untrusted documents.
Final recommendation
Choose the parser that preserves the information your application must answer questions about. Start with a small gold corpus, run each tool in its appropriate mode, compare page-level text, reading order, tables and provenance, then normalize into your own schema. Keep parsing, chunking and retrieval evaluation as separate stages.
If you cannot point a retrieved answer back to the correct source page, the ingestion pipeline is not finished—no matter how clean the Markdown looks.
