Use

MarkItDown for LLM and RAG pipelines

Updated 2026-11-16·Upstream source ↗
Markdown view

MarkItDown produces Markdown that models read well, and that mostly helps retrieval: headings, lists and tables survive from Office files. The gaps are known: PDFs have no headings, scanned pages are empty, and Excel blanks become NaN. We measured tokens on three documents and tested a heading-based chunker; we did not test the LangChain or LlamaIndex loaders.

Short answer

  • Word, PowerPoint, HTML: good structure to chunk on.
  • Text PDFs: clean text without headings: chunk by size or page.
  • Scans: nothing without OCR (OCR).
  • Excel: tables with NaN to clean (recipe).

Tested with markitdown 0.1.9 · Python 3.13 · markitdown 0.1.9 · three sample documents for token counts with two tokenizers (T22); LangChain and LlamaIndex loaders were NOT tested · 2026-11-16 · evidence: token-counts.csv, format-matrix-summary.csv

Tokens: Markdown against plain text and HTML

The same three documents as raw extracted text, as HTML and as MarkItDown Markdown, with two tokenizers
DocumentFormCharactersTokens (cl100k_base)Tokens (o200k_base)
report.docxraw extracted text665191186
report.docxHTML1165451449
report.docxMarkItDown Markdown838266261
pdf-text.pdfraw extracted text927189188
pdf-text.pdfHTML1053267267
pdf-text.pdfMarkItDown Markdown926188187
workbook.xlsxraw extracted text291133131
workbook.xlsxHTML1770708716
workbook.xlsxMarkItDown Markdown526209218
The same three documents as raw extracted text, as HTML and as MarkItDown Markdown, with two tokenizers Source: Test T22 · markitdown 0.1.9 · 2026-11-15 · token-counts.csv · Download CSV

Markdown cost more tokens than raw text for the Word file (266 against 191) and the workbook (209 against 133), which is the price of keeping headings and table structure, and far fewer than HTML (451 and 708). The text PDF came out the same as raw text (188 against 189), because MarkItDown adds no structure there. Three documents are a small sample: do not extrapolate.

Chunking MarkItDown output

Split on headings where they exist

Pythonapi-chunk-headings.py
import re
from markitdown import MarkItDown

md = MarkItDown()
text = md.convert("samples/report.docx").markdown
# split before every heading of level 1 to 3 and keep the heading with its text
chunks = [c.strip() for c in re.split(r"(?m)^(?=#{1,3} )", text) if c.strip()]
for i, chunk in enumerate(chunks):
    print(f"chunk {i}: {len(chunk):>4} characters, starts {chunk.splitlines()[0]!r}")
Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-16
chunk 0:   33 characters, starts 'Pilot Report: Field Station Alpha'
chunk 1:  113 characters, starts '# 1. Summary'
chunk 2:  147 characters, starts '## 1.1 Key findings'
chunk 3:   79 characters, starts '## 1.2 Next steps'
chunk 4:  224 characters, starts '# 2. Measurements'
chunk 5:   79 characters, starts '## 2.1 Chart'
chunk 6:  151 characters, starts '### 3. Deep heading level three'

captured result

For PowerPoint, split on the slide-number comment (PowerPoint page); for Excel, on the ## sheet headings (Excel page).

PDFs have no headings

Chunk by size or page; the output has no page markers, so citing a page needs another approach (PDF page). We did not test a page-range workaround.

Keep tables whole

A chunk boundary inside a pipe table separates the header from its rows. We did not measure the effect on retrieval.

Clean before embedding

Blank NaN cells, truncated image placeholders and repeated page headers and footers are in the output; see the format pages for the tested clean-up steps.

LangChain and LlamaIndex

We did not test any loader or reader built on MarkItDown, so we cannot say which exist or whether they work with current versions.

Metadata to keep

Source path, file type and the MarkItDown version, because output changes between releases (releases). The result object has .markdown and .title; we did not find per-page information in it.

Doing many files

Reuse one converter in one process (batch page).