induwara.lk
induwara.lkAI · Developer tools

RAG Chunk Size & Overlap Calculator

Size a retrieval-augmented-generation pipeline before you write any code. Enter a document length, chunk size and overlap to get the exact chunk count, tokens duplicated by overlap, the embedding cost in USD, and how large the vector index will be. Runs entirely in your browser — no keys, no upload.

By Induwara AshinsanaUpdated Jul 8, 2026
Size your RAG indexchunks · cost · store
Runs in your browser · no keys

Total size of everything you're indexing.

Tokens per chunk before overlap.

Tokens repeated from the previous chunk.

Common recipes

Chunks fetched per query.

Chunks produced
224
Stride 448 tokens/step
Duplicated tokens
14,272
14.27% of the document
Total tokens embedded
114,272
Document + overlap duplication
Embedding cost
$0.0023
One-time, per index build
Vector store size
1.31 MiB
Raw vectors, excl. index overhead
Retrieval prompt budget
2,560 tok
Injected per query at top-k

Sliding-window breakdown

ChunkToken rangeSpan
#10512512
#2448960512
#38961,408512
220 more chunks
#22499,904100,00096

Vector store size is the raw embedding payload (chunks × dimensions × bytes-per-value). Real databases add index structures (HNSW/IVF) and metadata on top, so treat this as a floor, not a total.

Prices and model limits are hard-coded from each provider's docs (cited below) and verified periodically. Pick Custom to override.

How it works

Fixed-size chunking slides a window of chunk_size tokens across your document, advancing by a strideeach step. The stride is the chunk size minus the overlap. Every calculation below is deterministic sliding-window arithmetic — the same logic LangChain's RecursiveCharacterTextSplitter and LlamaIndex's SentenceSplitter use to advance the window.

Let N be the document length in tokens, w the chunk size, o the overlap and s = w − o the stride.

  1. Token estimate.Tokens are used as entered. Characters are converted at about 4 characters per token, and words at about 1.33 tokens per word, following OpenAI's tokenizer guidance. These heuristics are close for English prose but not exact.
  2. Chunk count. If N ≤ w the whole document is a single chunk. Otherwise the count is ceil((N − o) / s). This is algebraically identical to ceil((N − w) / s) + 1; the tool computes both and they always agree, which is how you can trust the number.
  3. Duplicated tokens. Every chunk after the first repeats exactly o tokens from its predecessor, so the overlap adds (chunks − 1) × o tokens on top of the document.
  4. Total tokens embedded = N + (chunks − 1) × o. You pay to embed every one of them, including the duplicates.
  5. Embedding cost = total_tokens ÷ 1,000,000 × price_per_1M, with the price taken from the selected model (OpenAI text-embedding-3-small at $0.02/1M, -3-large at $0.13/1M, ada-002 at $0.10/1M, Cohere embed-english-v3.0 at $0.10/1M, Voyage voyage-3 at $0.06/1M) or your custom figure. This is a one-time cost per index build.
  6. Vector store size = chunks × dimensions × bytes_per_value, where a float32 value is 4 bytes, float16 is 2 and int8 is 1. Dimensions come from the model (1536, 3072 or 1024). This is the raw vector payload; database index structures and metadata sit on top of it.
  7. Retrieval prompt budget = top_k × wtokens. This is the upper bound of context your retriever injects into the prompt each query — keep it well under the generation model's context window.

Two guards protect you from silent mistakes: overlap must be smaller than the chunk size (otherwise the window never advances), and if a chunk is larger than the embedding model's maximum input the provider truncates it, so the tool warns you.

Worked examples

250-page manual · OpenAI small model

N = 100,000 tokens · chunk 512 · overlap 64 · text-embedding-3-small · float32 · top-k 5

  1. Stride: s = 512 − 64 = 448
  2. Chunks: ceil((100,000 − 64) / 448) = ceil(223.07) = 224
  3. Duplicated: (224 − 1) × 64 = 14,272 tokens (14.3% overhead)
  4. Total embedded: 100,000 + 14,272 = 114,272 tokens
  5. Cost: 114,272 ÷ 1,000,000 × $0.02 = $0.0023
  6. Store: 224 × 1536 × 4 = 1,376,256 B ≈ 1.31 MiB
  7. Retrieval budget: 5 × 512 = 2,560 tokens/query

Short doc · large model · bigger chunks

N = 3,000 tokens · chunk 1,000 · overlap 200 · text-embedding-3-large · float32 · top-k 3

  1. Stride: s = 1,000 − 200 = 800
  2. Chunks: ceil((3,000 − 200) / 800) = ceil(3.5) = 4
  3. Windows: 0–1000, 800–1800, 1600–2600, 2400–3000 ✓
  4. Duplicated: (4 − 1) × 200 = 600 tokens (20% overhead)
  5. Total embedded: 3,000 + 600 = 3,600 tokens
  6. Cost: 3,600 ÷ 1,000,000 × $0.13 = $0.000468
  7. Store: 4 × 3072 × 4 = 49,152 B = 48 KiB

Edge case · document shorter than one chunk

N = 300 tokens · chunk 512 · overlap 64

  1. N (300) ≤ chunk size (512), so the whole document is one chunk.
  2. Chunks: 1 · Duplicated: 0 · Total embedded: 300 tokens
  3. There is nothing to overlap with, so overlap has no effect here.

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want another embedding model added?

Email me at [email protected] — most fixes ship within 24 hours.