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.
| Library | Type | How It Works |
|---|---|---|
| Unstructured | Dedicated parser | Reads 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 |
| Docling | AI-powered parser | Uses AI models to detect the page layout and table structure; OCR for scanned pages |
| MarkItDown | Format converter | Converts files to Markdown, with tables as pipe tables and code in fenced blocks |
| Apache Tika | Java server | Python sends file to a background Java server over HTTP; server does all extraction |
| RAGParser | Lightweight parser | Returns labeled content blocks without models or a server |
| LlamaIndex | RAG framework | SimpleDirectoryReader auto-selects a reader per file extension |
| Haystack | RAG framework | Separate converter per format; plain text for PDF and Word, Markdown for Markdown and HTML |
| RAGFlow | Full platform | Docker-deployed application with web UI; not a library so excluded from automated benchmark |
How We Tested
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 |
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
| Library | TXT | MD | HTML | 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 |
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
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
| Library | TXT | MD | HTML | 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 |
*Tika’s parsing happens in its Java server, which isn’t included in these numbers.
Metadata Extraction
| Library | TXT | MD | HTML | 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 |
The Fundamental Trade-offs
| 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 |
Recommendations
| Use Case | Recommended Library | Why |
|---|---|---|
| Fastest working prototype | MarkItDown | No 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) | Docling | Best 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 elements | Unstructured | Labels 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 / auditing | Apache Tika | 77 metadata fields per Word document; the next highest returns 10 |
| Already using LlamaIndex or Haystack | Keep it, add Docling for PDF and Word | Their built-in readers return plain text for PDF and Word, so headings and lists are lost there |
| Serverless / edge deployment | RAGParser | Smallest start-up footprint, no models and no server. Finds tables in every format except plain text, but almost no lists |
| Turnkey self-hosted platform | RAGFlow | A complete platform with UI, parsing, chunking and retrieval, rather than a parser library |