Hack the Hydra

Markdown vs plain text for RAG

Short answer: index Markdown. It costs almost no extra tokens, and its headings and tables let you chunk on document structure and attach section context to every chunk, which generally improves retrieval compared with fixed-size chunks of plain text. Use plain text only when the source has no structure at all.

Free PDF to Markdown converter →

Free PDF to Markdown converter: the tool with a sample file converted

What does Markdown give you?

How do you chunk Markdown for RAG?

  1. Convert documents to Markdown (PDF, Word, HTML).
  2. Split on #, ## and ### headings.
  3. If a section is still too long, split it on paragraphs with a small overlap.
  4. Prepend the heading path to each chunk and store it as metadata.
  5. Evaluate on 20–50 real questions and tune chunk size.

When is plain text enough?

Chat logs, transcripts and short notes have no meaningful structure. Converting them to Markdown adds nothing; chunk them by time or by speaker instead.

Worked example: the same page, two ways

Take one page of an internal handbook with a heading, a short policy paragraph and a three-row table of refund deadlines. Extracted as plain text, the table becomes a run of words and numbers: Region Deadline Fee EU 14 days 0 US 30 days 5 UK 14 days 0. A retriever that receives the question "what is the refund deadline in the US?" has to match "US" and "30" across a flat string, and nothing in the chunk says that 30 is a deadline rather than a fee.

Extracted as Markdown, the same content keeps its shape:

## Refunds
Customers can ask for a refund within the deadline below.

| Region | Deadline | Fee |
|---|---|---|
| EU | 14 days | 0 |
| US | 30 days | 5 |
| UK | 14 days | 0 |

The chunk now carries its own labels. Prepending the heading path ("Handbook > Refunds") gives the embedding model the topic, and the model answering the question reads "US | 30 days" as a row, not a guess.

Plain text vs Markdown at a glance

Plain textMarkdown
Chunk boundariesFixed size or paragraphsHeadings, then paragraphs
Section contextLostHeading path as metadata
TablesFlattened, labels separated from valuesRows and columns kept
Token overheadNoneSmall (#, |, -)
Best forTranscripts, chat logs, notesManuals, reports, policies, docs

What are the common mistakes?

FAQ

Does Markdown cost more tokens?

Very little: a few characters per heading, list item or table row.

Do LangChain and LlamaIndex support Markdown splitting?

Yes, both provide Markdown header-based splitters.

What chunk size should I start with?

Start with sections split on headings and cap them around 300 to 800 tokens with a small overlap, then tune using your own test questions.

Last updated: November 2026. Facts about third-party tools come from their public repositories and documentation. Check licenses before commercial use.

Try it now

Free PDF to Markdown converter →