By Tim King · Updated
RAG Chunk Calculator
Chunk Count, Overlap Tokens and Vector Storage for a Retrieval-Augmented Generation Corpus
OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.
How the RAG Chunk Calculator works
This RAG chunk calculator plans how a corpus is split for retrieval-augmented generation. Enter the corpus size, chunk size and overlap to see how many chunks you get, how many extra tokens the overlap stores, the vector storage and how much context the top-k chunks fill.
How the RAG chunk calculator works
In retrieval-augmented generation, documents are split into chunks, each chunk is embedded, and at question time the k most similar chunks are pasted into the prompt. Overlap repeats the end of one chunk at the start of the next so a sentence cut at a boundary still appears whole somewhere. It costs extra tokens to embed and store, and the top-k chunks take k × chunk size tokens of the context window.
The formula for the number of chunks is ⌈(total − overlap) ÷ (size − overlap)⌉, and tokens stored = total + (chunks − 1) × overlap.
First example. 1,000,000 tokens in 512-token chunks with 51 tokens of overlap, about 10 percent, gives 2,170 chunks and 1,110,619 tokens stored, 11.1 percent overhead. At 1,536 dimensions the vectors take 13.33 MB as float32, and top-5 retrieval adds 2,560 tokens, about 1,920 words, to each prompt.
Second example. A 300-token document in 256-token chunks with 32 overlap gives 2 chunks and 332 tokens stored, 10.7 percent more than the original.
How many chunks should you retrieve? Three to ten is common; more raises recall but adds cost and noise to every prompt.
Chunks needed for a 1,000,000-token corpus by chunk size and overlap
| Chunk size (tokens) | Overlap (tokens) | Chunks | Extra tokens stored | Top-5 context (tokens) |
|---|---|---|---|---|
| 128 | 0 | 7,813 | 0.0% | 640 |
| 128 | 13 | 8,696 | 11.3% | 640 |
| 128 | 26 | 9,804 | 25.5% | 640 |
| 256 | 0 | 3,907 | 0.0% | 1,280 |
| 256 | 26 | 4,348 | 11.3% | 1,280 |
| 256 | 51 | 4,878 | 24.9% | 1,280 |
| 384 | 0 | 2,605 | 0.0% | 1,920 |
| 384 | 38 | 2,891 | 11.0% | 1,920 |
| 384 | 77 | 3,258 | 25.1% | 1,920 |
| 512 | 0 | 1,954 | 0.0% | 2,560 |
| 512 | 51 | 2,170 | 11.1% | 2,560 |
| 512 | 102 | 2,439 | 24.9% | 2,560 |
| 768 | 0 | 1,303 | 0.0% | 3,840 |
| 768 | 77 | 1,448 | 11.1% | 3,840 |
| 768 | 154 | 1,629 | 25.1% | 3,840 |
| 1,024 | 0 | 977 | 0.0% | 5,120 |
| 1,024 | 102 | 1,085 | 11.1% | 5,120 |
| 1,024 | 205 | 1,221 | 25.0% | 5,120 |
| 1,536 | 0 | 652 | 0.0% | 7,680 |
| 1,536 | 154 | 724 | 11.1% | 7,680 |
| 1,536 | 307 | 814 | 25.0% | 7,680 |
| 2,048 | 0 | 489 | 0.0% | 10,240 |
| 2,048 | 205 | 543 | 11.1% | 10,240 |
| 2,048 | 410 | 611 | 25.0% | 10,240 |
Tips and pitfalls
Smaller chunks match questions more precisely but lose surrounding context; larger chunks keep context but dilute the embedding. Split on headings, paragraphs and sentences rather than raw token counts where you can. Test chunk sizes against real questions, measuring whether the right passage comes back, rather than picking a number by habit.
FAQ
What chunk size should I use for RAG?
256 to 1,024 tokens covers most systems, with 512 a common starting point. Use smaller chunks for short factual answers such as FAQs and larger ones for narrative or technical documents where meaning spans paragraphs.
How much overlap is typical?
Ten to twenty percent of the chunk size, so 50 to 100 tokens on a 512-token chunk. Overlap helps when splitting by token count; when you split on paragraph or section boundaries, little or none is needed.
Why does overlap increase storage?
Every overlapped token is stored and embedded twice, once at the end of one chunk and once at the start of the next. With 2,170 chunks and 51 tokens of overlap, that is 110,619 extra tokens.
How much context does top-k retrieval use?
k × chunk size tokens, before the system prompt, question and answer. Five 512-token chunks use 2,560 tokens; twenty 1,024-token chunks use 20,480, which is costly on every single question.
Does the calculator split my documents?
No. It plans the numbers from sizes you enter. Real splitters respect sentence and heading boundaries, so actual chunk counts come out slightly higher than the formula, which assumes every chunk is full.
See also: all AI tools, Dev Utilities, Formatters & Validators, Data & Encoding, Security & Identifiers, SEO, Accessibility.
Related tools
Embedding Cost Calculator
Estimate what it costs to embed documents and how much storage the vectors take.
Context Window Calculator
Check whether a prompt, documents and reply fit a model's context window.
LLM Cost Calculator
Price LLM API calls per request and per month, with caching.
AI Token Counter
Count GPT tokens in a prompt or document with o200k_base, in your browser.
Word Counter
Words, six readability scores, keyword density and platform limits.