Markdown Chunker for RAG
Split a document into chunks of an exact token size — at headings and paragraphs, never inside a code block — and export them as JSONL for your vector database.
Drop a PDF, Word or text file, or browse
Chunking decides what retrieval can find
In a retrieval-augmented generation (RAG) pipeline, documents are cut into chunks, each chunk is embedded, and the chunks closest to a question are handed to the model. A chunk that mixes two topics matches neither well; a chunk cut mid-table or mid-function is useless when retrieved. Splitting on the document's own structure avoids both.
That structure has to exist first. PDFs, the most common source, carry none — so convert them to Markdown with PDF to Markdown (or drop them here, which does the same), and read PDF to Markdown for RAG pipelines for the rest of the pipeline. To check a single chunk or prompt, use the token counter.
Frequently asked questions
How does it decide where to cut?
Structure first. Every heading starts a new chunk. Within a section, whole blocks — paragraphs, lists, tables, fenced code — are packed together until the next one would go over the token limit. Only a block that is larger than the limit on its own is split further, at sentence boundaries, and as a last resort between words. Code blocks and tables are never cut in the middle unless they are larger than a chunk.
What chunk size should I use?
There is no universal answer, but 256–1,000 tokens is the usual range for retrieval: small enough that a retrieved chunk is about one thing, large enough to carry its context. Check your embedding model’s input limit — OpenAI’s text-embedding-3 models accept up to 8,191 tokens — and test retrieval quality on real questions.
What does overlap do?
It repeats the last few dozen tokens of one chunk at the start of the next, so a sentence that straddles a boundary can still be found from either side. 10–15% of the chunk size is a common starting point; overlap never crosses a heading, since a new section starts fresh.
Why repeat the headings in each chunk?
A chunk that says “Set the timeout to 30 seconds” is ambiguous on its own; prefixed with “# API guide > ## Retries”, it is not. Repeating the heading path makes every chunk self-describing, which usually improves both retrieval and the answer generated from it.
What is in the JSONL file?
One JSON object per line: id, text, tokens, headings (the heading path as a list) and the tokenizer used. It loads directly into most vector-database import tools, LangChain and LlamaIndex, or a few lines of Python.
Is my document uploaded?
No. Text extraction, tokenization and chunking all run in your browser, in a background thread.
Limitations
- Token sizes are exact for OpenAI tokenizers; other models count differently.
- Headings are recognised in Markdown syntax (#); plain text is split by paragraphs and sentences.
- A single code block or table larger than the chunk size is split, as it cannot fit otherwise.
- The preview shows the first 200 chunks; downloads always contain all of them.
Related tools
- Token CounterExact OpenAI token counts for text, PDFs and Word files.Text, PDF, Word (.docx), Markdown, HTML → Token count
- PDF to MarkdownClean Markdown from any PDF, with OCR for scanned pages.PDF → Markdown (.md)
- Split PDF for AICut a PDF into parts NotebookLM, ChatGPT or Claude will accept.PDF → PDF parts, ZIP
- HTML to MarkdownPaste HTML, a web page or a Google Doc — get Markdown.HTML, Clipboard → Markdown (.md)
Guides
- How to Chunk Documents for RAG: Sizes, Overlap and StructureA practical guide to splitting documents for retrieval-augmented generation - chunk sizes, overlap, heading context, and why structure beats fixed-size splits.
- PDF to Markdown for RAG Pipelines (Practical Guide)Why clean Markdown improves RAG retrieval quality. Covers chunking strategies, metadata, common PDF extraction pitfalls, and where browser tools fit.
- Why LLMs Read Markdown Better Than PDF (ChatGPT & Claude)PDF extraction throws away the structure your model needs. See what breaks, and why Markdown gets better answers out of ChatGPT and Claude.
- AI File Upload Limits in 2026 — NotebookLM, ChatGPT, Claude, GeminiWhat NotebookLM, ChatGPT, Claude and Gemini actually accept per file, what happens when you go over, and the two fixes that work - with sources and dates.