Use
MarkItDown for LLM and RAG pipelines
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
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
| Document | Form | Characters | Tokens (cl100k_base) | Tokens (o200k_base) |
|---|---|---|---|---|
report.docx | raw extracted text | 665 | 191 | 186 |
report.docx | HTML | 1165 | 451 | 449 |
report.docx | MarkItDown Markdown | 838 | 266 | 261 |
pdf-text.pdf | raw extracted text | 927 | 189 | 188 |
pdf-text.pdf | HTML | 1053 | 267 | 267 |
pdf-text.pdf | MarkItDown Markdown | 926 | 188 | 187 |
workbook.xlsx | raw extracted text | 291 | 133 | 131 |
workbook.xlsx | HTML | 1770 | 708 | 716 |
workbook.xlsx | MarkItDown Markdown | 526 | 209 | 218 |
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
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}")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' 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).