A Real Benchmark of Document Parsing Libraries and Their Capabilities for RAG-Based AI Applications

Every RAG system starts with a parser. It turns PDFs, Word files and web pages into text a model can work with. It also decides how much of the document’s structure is kept, such as headings, tables, lists and code blocks. If the parser loses that structure, the chunking and embedding steps cannot get it back.

In practice, the parser is often chosen once and rarely checked again. In this post we compare seven popular parsing libraries to find out which one to use and what each one costs in speed and memory.

Key findings

  • Docling kept the most structure overall and did best on PDF. It needed 22 seconds per PDF.
  • Only Docling and Unstructured found the headings and lists in our PDF, and they needed 22 and 27 seconds per PDF. The other five libraries finished in under half a second but found no headings.
  • No library recognized the code block in our PDF or Word file.
  • Tika returned 77 metadata fields for the Word document. The next highest was 10.
  • For most teams we suggest MarkItDown to start, Docling when PDFs or accuracy matter, and Unstructured when you need labeled elements and can accept its slower high-resolution mode.

The Libraries

We looked at eight popular tools that handle multiple file formats. Seven are libraries and went through the benchmark. RAGFlow is a complete platform rather than a library, so we describe it here but didn’t run it.

LibraryTypeHow It Works
UnstructuredDedicated parserReads and labels every content element (heading, table, paragraph, list item). For PDFs it has a fast text mode and a slower high-resolution mode that uses a layout model and OCR
DoclingAI-powered parserUses AI models to detect the page layout and table structure; OCR for scanned pages
MarkItDownFormat converterConverts files to Markdown, with tables as pipe tables and code in fenced blocks
Apache TikaJava serverPython sends file to a background Java server over HTTP; server does all extraction
RAGParserLightweight parserReturns labeled content blocks without models or a server
LlamaIndexRAG frameworkSimpleDirectoryReader auto-selects a reader per file extension
HaystackRAG frameworkSeparate converter per format; plain text for PDF and Word, Markdown for Markdown and HTML
RAGFlowFull platformDocker-deployed application with web UI; not a library so excluded from automated benchmark

How We Tested

We used five documents, one per format (TXT, Markdown, HTML, PDF and Word). Each contains many headings, tables, lists and code blocks. The PDF and the Word file have the same content, and the PDF has a text layer, so it is not a scan.

Every library ran with the settings its own documentation recommends for extracting structure from digital documents. We didn’t use cloud services, and we didn’t let one library call another. Four libraries needed changes.
Library What We Changed From the Defaults
Unstructured PDF: high-resolution mode with table detection. This needs the Tesseract OCR program installed on the machine
Docling PDF: OCR switched off, since our PDF has a text layer
Haystack Converters set up as in Haystack’s own multi-format converter (Markdown read as is, HTML converted to Markdown). Word tables as Markdown, which is one of two documented options
Apache Tika PDF: extract tagged content, no OCR
MarkItDown, RAGParser, LlamaIndex Defaults, as their documentation suggests no changes for this. RAGParser’s built-in chunking is switched off so that it only parses, like the others
The settings made a bigger difference than we expected. With its default settings, Unstructured reported 207 headings in our four-page PDF, which has 20, and found none of its eight tables. In the high-resolution mode its documentation recommends when element types matter, it found 19 of the headings and all eight tables.

To measure accuracy, we listed every real heading, table, list and code block in each document. Then we checked what each library returned against that list, so a heading only counts if it matches a real one. We report recall (how much of the real structure was found), precision (how much of what was returned is real) and F1, which combines the two. Counts alone would be misleading here. Unstructured’s 207 headings from the default mode would have scored 100% if we had only checked that it found at least 20.

Each library ran in its own process. After one warm-up run per document, we timed five runs and report the median. Memory is the peak a single parse adds on top of what the process already used. Loading models at start-up is measured separately.

All tests used the latest versions in October 2026: Docling 2.135, Unstructured 0.27, MarkItDown 0.1.8, Apache Tika 3.3.2, RAGParser 1.0.5, LlamaIndex 0.14 and Haystack 3.3.

Results

Speed

The speed differences across libraries were more dramatic than we expected.
Library TXT MD HTML PDF DOCX
LlamaIndex 3 ms 3 ms 18 ms 58 ms 11 ms
Haystack 2 ms 2 ms 37 ms 60 ms 67 ms
Tika 42 ms 24 ms 51 ms 73 ms 118 ms
RAGParser 13 ms 22 ms 39 ms 403 ms 102 ms
MarkItDown 9 ms 9 ms 45 ms 310 ms 426 ms
Unstructured 43 ms 61 ms 45 ms 26,614 ms 459 ms
Docling 56 ms 160 ms 181 ms 22,043 ms 632 ms
LlamaIndex, Haystack and Tika stay at about 120 milliseconds or less for every format. They use lightweight converters and no models, which also explains their lower accuracy scores further down.

Docling and Unstructured are much slower on PDF because both run AI models on every page. Docling takes 22 seconds per PDF and Unstructured’s high-resolution mode 27 seconds. Both also need time to start. Docling spends about 20 seconds loading its models, and Unstructured’s first PDF took almost two minutes.

Structural Accuracy

We scored headings, tables, lists and code blocks. The heatmap shows the F1 score per library and format. A high score means a library found most of the real structure and returned little that wasn’t there. Plain text results should be treated as rough indicators, since there is no standard way to mark a heading in a .txt file.
Overall structural accuracy, mean F1 % by library and format
Markdown and HTML were easy for most libraries because the structure is written into the markup. The PDF results show much bigger differences.
Library Headings (20) Tables (8) Lists (5) Code Blocks (1)
Docling 20 8 5 0
Unstructured 19 8 3 0
RAGParser 0 8 0 0
MarkItDown 0 7 0 0
Tika 0 0 0 0
LlamaIndex 0 0 0 0
Haystack 0 0 0 0

Real items found in the PDF, out of the number in brackets.

Five of seven libraries found no headings in the PDF. Docling found all 20 and Unstructured 19. Docling, Unstructured and RAGParser found all eight tables, though each of them returned one table twice because it runs across a page break. MarkItDown found seven of the eight and broke several tables into pieces.

No library recognized the code block in the PDF or the Word file. In both files it is just a paragraph set in a monospace font, with nothing that marks it as code. In Markdown and HTML, where code is marked, almost every library found every code block.

LlamaIndex and Haystack are fast because they do little processing, and their scores reflect that. Both read Markdown as it is written, so they score perfectly there. For PDF and Word, their built-in converters return plain text, and headings and lists are lost. Haystack still keeps the tables in Word and HTML. LlamaIndex keeps nothing in PDF, Word or HTML.

Unstructured scores lowest on plain text. It merges most headings into the paragraph that follows them, and it labels the numbered section titles as list items.

Memory Usage

For most formats, memory differences between libraries are small and unlikely to influence infrastructure decisions. PDF is the exception again.
Library TXT MD HTML PDF DOCX
Tika* 0 MB 0.1 MB 0.7 MB 0 MB 0.1 MB
LlamaIndex 0 MB 0 MB 0.5 MB 0.2 MB 0 MB
Haystack 0 MB 0 MB 0.1 MB 0.1 MB 4.0 MB
MarkItDown 0 MB 0 MB 0.7 MB 0.1 MB 5.9 MB
RAGParser 0 MB 0.2 MB 0.7 MB 13.3 MB 5.8 MB
Docling 0.3 MB 0.7 MB 0.5 MB 153.0 MB 5.6 MB
Unstructured 0 MB 0.3 MB 0.1 MB 174.6 MB 0.2 MB
Five libraries stay under 15 MB for a PDF parse. Docling and Unstructured, the two that run models on every page, need around 150 to 175 MB per PDF, and that is with the models already loaded. Loading Docling’s models takes another 870 MB once, at start-up. Neither is a drop-in for serverless or memory-constrained environments, and Unstructured’s high-resolution mode also needs Tesseract installed on the machine.

*Tika’s parsing happens in its Java server, which isn’t included in these numbers.

Metadata Extraction

Metadata gets little attention in most parser comparisons, but RAG systems need it to filter results and to show where an answer came from.
Library TXT MD HTML PDF DOCX
Tika 11 11 23 47 77
RAGParser 9 9 11 12 10
LlamaIndex 6 6 7 7 6
Unstructured 5 5 5 5 5
Docling 3 3 3 3 3
Haystack 1 1 1 1 6
MarkItDown 0 0 1 0 0
Tika returns 77 metadata fields for the Word document, including the author, creation date, revision count, page count and the application that created it. The next highest is RAGParser with 10. We only counted fields that came back with a value, and several of the smaller numbers are mostly file details such as the file name and type. Without this kind of metadata, you can’t filter results by author or date.

The Fundamental Trade-offs

The table below summarizes how the libraries compare on all four measures.
Speed Structural Accuracy Metadata Memory
Docling Slow on PDF (22 s) Highest Low (file details only) Heavy on PDF (153 MB, plus 870 MB to load models)
Unstructured Slowest on PDF (27 s) High, weak on plain text Moderate Heavy on PDF (175 MB)
MarkItDown Fast High on Markdown, HTML and Word; tables only on PDF None Light
Tika Fast* High on Markdown and HTML, no lists in Word, none on PDF Most fields by far Light*
RAGParser Fast Moderate: tables yes, lists almost never Moderate Light
LlamaIndex Fastest Low: text formats only Moderate Light
Haystack Fastest Low: text formats, plus tables in HTML and Word Low Light
*Tika’s speed and memory are measured on the Python side. The Java server itself adds its own footprint.

Recommendations

Use CaseRecommended LibraryWhy
Fastest working prototypeMarkItDownNo configuration, clean Markdown output, under half a second for every format, and almost every heading, table and list in Markdown, HTML and Word
Complex PDFs (reports, specs, papers)DoclingBest structural accuracy overall and the best PDF results, with every heading, table and list in our test PDF. Budget about 20 seconds per PDF
Structure-aware chunking with labeled elementsUnstructuredLabels every element with its type. In high-resolution mode it nearly matches Docling on PDF headings and tables, but it is the slowest on PDF and needs Tesseract
Enterprise search / compliance / auditingApache Tika77 metadata fields per Word document; the next highest returns 10
Already using LlamaIndex or HaystackKeep it, add Docling for PDF and WordTheir built-in readers return plain text for PDF and Word, so headings and lists are lost there
Serverless / edge deploymentRAGParserSmallest start-up footprint, no models and no server. Finds tables in every format except plain text, but almost no lists
Turnkey self-hosted platformRAGFlowA complete platform with UI, parsing, chunking and retrieval, rather than a parser library

Leave a Reply

Your email address will not be published. Required fields are marked *