How to convert documents to Markdown for RAG with an AI agent
Leave feedback
On this page
Retrieval pipelines start with a conversion step, and that step decides how good the retrieval will be. Markdown is the format most chunkers and embedders handle best: headings survive, tables stay tables, lists stay lists.
Note
The commands and config snippets on this page are for the .NET build of the server — the only platform available today. Installation and client setup: MCP server for .NET. Other platforms will expose the same tools with their own launch command; everything else on this page applies unchanged.
The pattern
Put the corpus in the storage folder the server can see.
Ask: “Convert every PDF in this folder to Markdown, images as files, with front matter.”
.md files (and an image folder) land in your output folder, ready to chunk.
Choose images: "file" for ingestion
The default embeds images as base64 data URIs, which makes a self-contained file — and makes a terrible RAG corpus: a single picture becomes a multi-megabyte blob sitting in the middle of a chunk, and your embedder gets a page of base64 instead of a paragraph of text.
For an index, use images: "file" (pictures written alongside, referenced by path) or skip images entirely when only the prose matters.
Turn on front matter
frontMatter: true writes YAML with title, author, format, and page count at the top of each file. That is chunk metadata you would otherwise have to reconstruct from file names — and it lets a retrieval answer cite “the Employee Handbook, page 42” instead of “handbook-final-v3.md”.
The trap that ruins ingestion runs
Evaluation mode converts only the first three pages. Nothing errors, nothing warns; you get a valid .md that contains the first three pages of a 200-page manual. Build an index from it and every retrieval quietly fails to find what it should.
Make the check the first step of any run:
Before converting anything: what is the license status of the markdown server?