Chunk Size Calculator
Calculate the number of chunks produced when splitting a document for RAG retrieval.
About Chunk Size Calculator
RAG chunking splits a document into overlapping windows so that context near chunk boundaries isn't lost: num_chunks = ceil(document_length / (chunk_size − overlap_tokens)), where overlap_tokens = chunk_size × overlap%. Larger chunks capture more context per retrieval but reduce precision (more irrelevant text mixed in) and risk exceeding the embedding model's context window; smaller chunks improve retrieval precision but multiply storage and embedding cost, and overlap adds redundancy that trades extra storage for continuity across chunk boundaries.
Formula
num_chunks = ceil(doc_length / (chunk_size - chunk_size * overlap_percent / 100))
- doc_length
- Average document length in tokens
- chunk_size
- Chunk size in tokens
- overlap_percent
- Overlap between consecutive chunks as a percentage
Worked example
With the default values below, Chunk Size Calculator returns Number of Chunks of 19. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Avg. Document Lengthaccepts 1–10,000,000 tokens
- 8,000 tokens
- Chunk Sizeaccepts 1–1,000,000 tokens
- 512 tokens
- Embedding Model Context Windowaccepts 1–10,000,000 tokens
- 8,191 tokens
- Overlapaccepts 0–90 %
- 15 %
Results
- Number of Chunks
- 19
- Effective New Content per Chunk
- 435 tokens
- Overlap Tokens
- 77 tokens
- Storage Redundancy from Overlap
- 17.8%
Step by step
- 1Overlap tokens: chunk size × overlap %= 77 tokens
- 2Effective stride (new content per chunk): chunk size − overlap tokens= 435 tokens
- 3Number of chunks: ⌈document length ÷ effective stride⌉= 19
- 4Redundancy from overlap: (total embedded tokens − doc length) ÷ total embedded tokens= 17.8%
Assumptions and limits
- The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 1 decimal place, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
What's a good default chunk size?
300-800 tokens is a common starting range for general text RAG — small enough for precise retrieval, large enough to retain coherent context; the right value depends on your content type (dense technical text often benefits from smaller chunks, narrative text from larger ones).
Why use overlap between chunks at all?
Without overlap, a sentence or idea split exactly at a chunk boundary can lose context in both resulting chunks; overlap ensures each chunk contains a 'tail' of the preceding chunk's content so boundary-spanning information isn't lost.
What happens if chunk size exceeds the embedding model's context window?
The embedding API will typically truncate the input to fit its context window, silently discarding the excess text — always keep chunk size safely below the embedding model's maximum context window.
How does overlap affect storage cost?
Higher overlap percentages increase the number of chunks needed to cover a document (since each chunk contributes less new content), which directly increases both embedding cost and vector storage — see the Redundancy result for exactly how much duplicate content this adds.
