Developer & Tech

RAG Chunking Calculator

What this does

Work out how many chunks an overlapping-window chunking strategy produces, plus stored-token overhead and embedding cost.

Enter your details

Runs in your browser

Calculator inputs

Using the rag chunking calculator

  1. 01

    Measure the corpus in tokens

    Use our token counter on representative documents rather than word counts.

  2. 02

    Choose chunk and overlap

    512/64 is a common starting point; retrieval quality should tune it, not habit.

  3. 03

    Price the embedding run

    Stored tokens include duplication; the honest figure for API budgeting.

Why overlap exists

Fixed cuts slice sentences and ideas in half. Overlap gives each chunk a running start into its neighbor’s territory, so a fact straddling a boundary lives fully inside at least one embedded chunk. The cost is duplicate storage; visible here as an overhead percentage.

Bigger chunks vs better retrieval

Larger chunks preserve more context per hit but blur relevance signals and burn query-time context. Smaller chunks retrieve precisely but fragment reasoning. Practitioners commonly sweep 256–1024 tokens against real queries instead of trusting defaults.

The math behind this calculator

chunks = ⌈(doc − overlap) ÷ (chunk − overlap)⌉ stride = chunk − overlap stored = chunks × chunk

Overlapping windows advance by the stride (chunk minus overlap) each step, so a document of D tokens with chunk C and overlap O yields ceil((D − O) ÷ (C − O)) chunks. Every chunk stores its full size including duplicated context, and multiplying stored tokens by your embedding price prices the indexing run.

Assumptions & limitations

  • Sliding fixed-size windows; semantic/sentence-aware splitters differ.
  • Overlap must be strictly smaller than chunk size.
  • Embeddings billed per token at your entered rate.

Worked example

A 10,000-token document split into 512-token chunks with 64-token overlap yields 23 chunks (ceil((10000 − 64) / (512 − 64))); about $0.0002 of embeddings at $0.02/Mtok.

Frequently asked questions

Why was my equal overlap rejected?
Overlap ≥ chunk size means zero stride; the window never advances and chunking never terminates. Progress requires strict overlap < chunk.
Does chunking affect query cost too?
Yes; retrieved chunks enter the prompt. More, smaller chunks raise per-query input tokens even though they sharpen retrieval.
Is fixed-size splitting optimal?
Rarely perfect. Sentence- and section-aware splitters respect structure; this calculator still approximates their output well for planning.

Related calculators