RAG Document Chunk Count, Sliding Overlap & Embedding Token Calculator

Compute exact chunk count ceil((Tokens − Overlap) / (ChunkSize − Overlap)).

Total Vector Chunks Generated 35,000 chunks
Chunks Generated per Document 7 chunks/doc
Total Embedded Tokens (Millions) 17.92 M tokens
Overlap Token Expansion Ratio 1.12 ×
Inputs
Try:
docs
Total number of source documents in corpus.
tokens/doc
Average token count per source document.
tokens
Target token size per text chunk.
tokens
Sliding-window token overlap between adjacent chunks.
Results & Graph
Total Vector Chunks Generated
35,000 chunks
Chunks Generated per Document
7 chunks/doc
Total Embedded Tokens (Millions)
17.92 M tokens
Overlap Token Expansion Ratio
1.12 ×

Total Vector Chunks Generated

Graph 1 • How the inputs feed RAG Chunking & Overlap
RAG Document Chunk Count, Sliding Overlap & Embedding Token Calculator • Custom Domain Schematic (AI & LLM Infrastructure) documentavgTokenOut Document Count: 5.0k docs • Avg Tokens Per Document: 3.2k tokens/doc TOTAL VECTOR CHUNKS GENERA 35,000 chunks • Chunks Generated per D: 7 chunks/doc • Total Embedded Tokens : 17.92 M tokens Eq: Stride = ChunkTokens − OverlapTo
Graph 2 • Total Vector Chunks Generated as Document Count changes (40% to 160% of current)
0 chunks 30.8k chunks 61.6k chunks 14.0k 2.0kdocs 21.0k 3.0kdocs 28.0k 4.0kdocs 35.0k 5.0kdocs 42.0k 6.0kdocs 49.0k 7.0kdocs 56.0k 8.0kdocs
Graph 3 • Document Count and Avg Tokens Per Document together Compares Total Vector Chunks Generated when Avg Tokens Per Document is shifted +25% (solid) vs. −25% (dashed).
0 chunks 32.2k chunks 64.4k chunks --- Avg Tokens Per Document @ 75% 31.5k -30% 38.3k -15% 45.0k +0% 51.8k +15% 58.5k +30%
Summary: Splitting 5,000 documents (3200 tokens/doc) into 512-token chunks with 64-token overlap yields 7 chunks/doc (35,000 chunks total).
Summary: Splitting 5,000 documents (3200 tokens/doc) into 512-token chunks with 64-token overlap yields 7 chunks/doc (35,000 chunks total).
Interactive chart & math engine powered by CalculatorGraph

Formula: RAG Chunking & Overlap Systems Engineering Formula

Stride = ChunkTokens − OverlapTokens
ChunksPerDoc = ceil(max(1, (DocTokens − OverlapTokens) / Stride))
Stride = ChunkTokens − OverlapTokens; ChunksPerDoc = ceil(max(1, (DocTokens − OverlapTokens) / Stride))
  • documentCount: Document Count (docs)
  • avgTokensPerDocument: Avg Tokens Per Document (tokens/doc)
  • chunkSizeTokens: Chunk Size Tokens (tokens)
  • chunkOverlapTokens: Chunk Overlap Tokens (tokens)

Frequently Asked Questions

Does the first chunk also start with an overlap?

No. The first chunk begins at token zero and covers a full 512 tokens. Overlap only applies between neighbours, so every later chunk repeats the last 64 tokens of the one before it. That is why the formula subtracts the overlap once from the document length before dividing by the stride: the first chunk is not paying for any repeated text.

Should I count tokens or words for the average document size?

Count tokens with the tokenizer your embedding model uses. Chunk size and overlap are both measured in tokens, so a word count would mix units. Word to token ratios differ by language and by tokenizer, and code or tables tokenize very differently from prose. Tokenize a few hundred sample documents and take the average rather than estimating from word counts.

Why do I get exactly the same chunk count with zero overlap?

Because the default document happens to sit close to a step. With no overlap, 3200 divided by 512 is 6.25, which still rounds up to 7 chunks. Overlap only changed how full the seventh chunk was. What does change is the token line: it falls from 17.92 million to 16 million, and the ratio from 1.12 to 1.00, since no text is repeated.

Does the embedded token total include the empty end of the last chunk?

No. It counts document tokens plus the repeated overlaps, so a final chunk that ends short adds only the tokens it really holds. That makes it a fair basis for an embedding bill, with two caveats: it uses the average document length, and some providers add a few special tokens per request. Multiply by your price per million tokens and leave a small margin.

What happens if a document is shorter than the overlap?

It still makes one chunk. The formula takes the larger of 1 and document tokens minus overlap, so very short documents never produce zero or negative chunks. The chunk holds the whole document, nothing is repeated, and the expansion ratio is 1.00. The embedded tokens are just the document's own tokens, so a corpus of tiny notes costs few tokens but still one vector per note.

Do splitters that break on sentences or headings change the count?

Yes, a little. Structure-aware splitters move each boundary to the nearest sentence, paragraph or heading, so chunks vary in size and usually come out slightly smaller than the target. That tends to add a chunk here and there compared with this fixed token window. Use the calculator as a baseline and expect a structure-aware splitter to land somewhat above it.

Is overlap measured from the end of one chunk or the start of the next?

Both describe the same tokens. The last 64 tokens of one chunk are also the first 64 tokens of the next. In most libraries the overlap setting means exactly this shared span, and the step between chunk starts is chunk size minus overlap. If your splitter defines overlap differently, for instance as a percentage, convert it to tokens before entering it.

Does a larger corpus change chunks per document?

No. Chunks per document depends only on average document length, chunk size and overlap. Raising the document count from 3,000 to 7,500 scales total chunks and tokens in direct proportion, which the presets show, but leaves the 7 chunks per document and the 1.12 ratio untouched. Only a change in what the documents look like changes those two lines.

How should I handle a corpus with a few huge documents?

Run them separately. A handful of very long documents can pull the average up so far that the calculator applies one large ceiling to every file, which misrepresents both the short and the long ones. Enter the long documents as their own band with their own count and average, run the remaining documents as another band, and add the two chunk totals.

Why does an overlap as large as the chunk size give an error?

If the overlap equalled the chunk size, each chunk would start exactly where the previous one started, and the splitter would never move forward. A larger overlap makes even less sense. The calculator therefore asks for an overlap of zero or more and smaller than the chunk size. In practice overlap is usually a small fraction of the chunk.

Seven chunks per document on the default corpus

The default corpus is 5,000 documents averaging 3200 tokens each, split into 512 token chunks with 64 tokens of overlap between neighbours. The calculator returns 7 chunks per document and 35,000 chunks in total, and says you will send 17.92 million tokens to the embedding model.

The core idea is the stride. Each new chunk starts 512 minus 64 tokens after the previous one, because the first 64 tokens of every chunk repeat the last 64 of the chunk before it. The first chunk covers the opening 512 tokens. Every chunk after that adds only one stride of new text.

So the question is how many strides it takes to cover the rest of the document. The formula on the page writes it as the ceiling of document tokens minus overlap, divided by chunk size minus overlap. For the default that is 3200 minus 64, divided by 512 minus 64, which comes out at exactly 7. No rounding is needed, and the seventh chunk ends precisely on the last token of the document.

That exact fit is a coincidence of the default numbers, and it hides some of the behaviour you will see with your own corpus. Most real documents leave a partial chunk at the end, and the next sections look at what the calculator does with it.

When the document does not divide evenly

Change the average document to 3000 tokens and the division gives about 6.55 strides. The calculator rounds up to 7 chunks per document, because the leftover tail still needs its own chunk. You cannot embed two thirds of a chunk; the final chunk simply holds fewer tokens than the rest.

This rounding is why chunk count moves in steps rather than smoothly. Every document from about 2.75 thousand tokens up to 3200 lands on 7 chunks with the default settings. Add even a handful of tokens beyond 3200 and it jumps to 8. If you are close to one of these steps, a small change in chunk size or overlap can save or cost a whole chunk per document, multiplied by the full corpus.

To check a case by hand, take the document length, subtract the overlap, divide by the stride, and round any fraction up. If the result is below 1, the document fits in a single chunk. That is the max(1, ...) term in the formula: a document shorter than one chunk still produces one chunk.

The expansion ratio counts only repeated overlap

The third supporting line, the overlap token expansion ratio, is 1.12 on the default. It is computed as chunks per document times chunk size, divided by document tokens: 7 times 512, over 3200 tokens. Per document, the embedded tokens are the document itself plus one overlap for every chunk after the first: 3200 plus six overlaps of 64 tokens. Divided by 3200, that is the 1.12 shown, and the extra 12% is exactly the repeated overlap text.

The last chunk of a document is often only part full, and the calculator does not count the empty space. Set the overlap to zero and it still reports 7 chunks, because 3200 tokens need six full chunks and a short seventh. But the embedded tokens fall to 16 million, which is just the corpus, and the ratio falls to 1.00, since nothing is repeated.

Short documents behave the same way. A 64 token document makes one chunk with nothing repeated, so the ratio is 1.00 and the embedding model is sent just those 64 tokens, not a full 512 token window.

For the 3000 token example the calculator gives 7 chunks, 16.92 million tokens and a ratio of 1.13: the document plus six overlaps of 64. You can check any case by hand the same way, multiplying the overlap by the number of chunks minus one and adding the document length.

This makes the ratio a clean measure of what overlap costs you. If it reads 1.12, you are paying for 12% more embedding tokens than the corpus contains, and that share comes entirely from the repeated text at chunk boundaries.

Why the count is per document, not per corpus average

The calculator applies the ceiling once, to the average document, and multiplies by the document count. Real chunkers apply it to each document separately. When document lengths vary a lot, those two give different answers.

Picture a corpus that averages 3200 tokens but is really a mix of very short notes and a few long reports. Every short note still costs one full chunk, however small it is, and every long report rounds up its own tail. The per document rounding adds up to more chunks than the average suggests, often noticeably more when many documents are short.

The practical fix is to group your corpus into length bands and run the calculator once per band. For example, 3,000 documents at 3200 tokens give 21,000 chunks, the lower preset. Run a second band of short documents with their own average, then add the chunk totals together. Two or three bands are usually enough to get close to the true figure without listing every file.

Token counts should also come from the same tokenizer your embedding model uses. A word count, or a count from a different tokenizer, can be off by a meaningful margin and shifts every result on the page.

What each extra token of overlap costs

Overlap exists so that a sentence or idea cut at a chunk boundary still appears whole in at least one chunk. It is insurance for retrieval quality, and it is paid for in chunks and tokens.

Double the default overlap, from 64 to twice that, and the stride shrinks. The default document now needs 8 chunks instead of 7, the embedded tokens rise to 20.48 million, and the ratio rises to 1.28. That is one more chunk per document across all 5,000 documents, which is more vectors to store and more candidates for every search to score.

The cost grows quickly as overlap approaches the chunk size, because the stride shrinks toward zero. At an overlap equal to the chunk size the stride would be zero and the chunker would never move forward, so the calculator rejects any overlap that is not smaller than the chunk size and asks you to correct it. Chunk size itself must be at least 16 tokens.

A modest overlap is the usual compromise. Retrieval quality is something to test on your own questions; the calculator can only tell you what each setting costs.

Bigger chunks, fewer vectors, coarser retrieval

Chunk size is the most powerful input. Doubling it to twice 512 tokens, with the overlap left at 64, cuts the default document to 4 chunks: 3200 minus 64, divided by the new stride, is about 3.27, rounded up. The corpus shrinks to under two thirds of the default chunk count.

The embedded tokens fall to 16.96 million and the ratio to 1.06, because each document now has only three overlaps instead of six. The fourth chunk is far from full, but only its real tokens are counted.

Fewer, larger chunks mean a smaller index and fewer vectors to search, but each retrieved chunk carries more surrounding text. That can dilute the match for a narrow question and uses more of the language model's context window when several chunks are retrieved together. Smaller chunks give sharper matches at the cost of more vectors and more overlap overhead.

Whatever size you pick must fit inside your embedding model's maximum input length. The calculator does not know that limit, so check it in your model's documentation; text beyond the limit is usually truncated without an error.

Turning the token total into a budget and an index size

The two headline outputs map directly onto the two costs of a retrieval system. Total embedded tokens drives the embedding bill. Multiply the millions of tokens by your provider's price per million tokens.

Total chunks drives storage and search. Each chunk becomes one vector, plus whatever metadata and original text you store alongside it. Multiply the chunk count by the bytes per vector, which is the embedding dimension times the bytes per number, to get the raw vector storage before any index overhead.

Remember that both costs recur. Changing the chunk size, the overlap or the embedding model means re-chunking and re-embedding the whole corpus, so it is cheaper to settle those choices on a sample before you index everything.

Scaling the corpus up or down

Document count is a straight multiplier. The lower preset with 3,000 documents gives 21,000 chunks and 10.75 million tokens; the higher preset with 7,500 documents gives 52,500 chunks and 26.88 million tokens. Chunks per document and the ratio do not change at all, because they depend only on document length, chunk size and overlap.

That makes the calculator useful for growth planning. Work out chunks per document once for a typical document, then scale by how many documents you expect to add each month. New documents only need embedding once, so ongoing cost follows the growth rate, while a change of chunking settings resets the whole corpus.