AI · RAG

LLM Context Window & RAG Chunking Calculator

Size your chunks, overlap, top-K retrieval, and prompt reserves before a 128K–1M token context window overflows. Everything is calculated locally in your browser.

Budget inputs

Live

Tip: keep 10–20% of the window as a safety buffer for tokenizer variance, tool schemas, and multi-turn history.

Budget analysis

Top-K trade-off

Each row assumes the current chunk size, prompt, output reserve, and safety buffer.

Top-K Retrieved Total load Window used Status
How do I choose chunk size and overlap for RAG?

Start with 500–1,000 token chunks and an overlap of 10–20% (roughly 64–200 tokens). Smaller chunks improve retrieval precision but increase chunk count and embedding cost; larger chunks preserve context but can dilute similarity scores. This calculator shows how your choices translate into token load per query.

Why isn't top-K × chunk size the whole prompt?

Retrieved chunks are only one part of the prompt. You must also add the system prompt, the user query, conversation history, tool schemas, and the reserved output tokens. Even a large 1M-token window can overflow once top-K, output reserves, and a safety buffer are accounted for.