Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

RAG Chunking Playground

Drop in any text and compare chunking strategies — fixed-size, recursive, by-sentence, by-paragraph — with overlap highlighted and an estimated token count per chunk. Stop guessing your chunk size; see exactly how your RAG pipeline will split a document.

Your document200 tokensToken counts are estimated (~4 chars/token).
Strategy
3 chunks66 avg tokens/chunk
#1 · 71 tok · 284 ch

Retrieval-augmented generation (RAG) grounds a language model in your own data.Before a model can retrieve a document, the document must be split into chunks and embedded.Chunk size is a balance.Large chunks preserve context but dilute relevance and burn context tokens at query time.

#2 · 56 tok · 224 ch

Small chunks are precise but can lose the surrounding meaning a passage depends on.Overlap repeats a little text across chunk boundaries.Without it, a sentence split across two chunks may become unretrievable for either one.

#3 · 70 tok · 280 ch

A typical starting point is a few hundred tokens per chunk with ten to twenty percent overlap.The right strategy depends on your content.Prose benefits from sentence or paragraph splitting; code or logs often suit fixed-size windows.Try a few here and watch how the chunks change.

A retrieval pipeline can only retrieve what it stored, and it stores chunks. Split badly and no prompt recovers: cut mid-sentence and you embed half-thoughts; make chunks huge and each embedding becomes a blurry average. This tool shows exactly how four common strategies split your text, chunk by chunk, with sizes.

What it computes

  • Fixed size: windows of size characters. Each window starts size − overlap characters after the last, where overlap = ⌊size × overlap% ⌋, and the last window ends at the end of the text.
  • Recursive: the text is broken at blank lines and after every ., ! or ? followed by whitespace. Pieces are appended to a buffer, and the buffer becomes a chunk whenever the next piece would push it past size.
  • By sentence: one chunk per run of text ending in sentence punctuation. Size is ignored.
  • By paragraph: one chunk per block separated by a blank line. Size is ignored.
tokens(chunk) = max(1, round(trimmed characters / 4))
average       = round(sum of chunk tokens / number of chunks)

A worked example

The sample document is four paragraphs about chunking, 801 characters, estimated at 200 tokens. The default strategy is recursive with a 300-character limit:

  1. The first paragraph’s two sentences fit, and so do the next two, ending “…at query time.” Adding the following sentence would pass 300 characters, so chunk 1 closes at 284 characters, 71 tokens.
  2. Chunk 2 takes the next three sentences, 224 characters and 56 tokens; chunk 3 takes the last four, 280 characters and 70 tokens.
  3. The summary reads 3 chunks and 66 avg tokens/chunk.
Strategy (defaults)ChunksAverage tokensWhat the boundaries look like
Recursive, 300 chars366Whole sentences, sizes 224 to 284 characters
Fixed, 300 chars, 15%374Windows start at 0, 255 and 510; cuts land mid-word, as in “Small chunk” and “urn context”
By sentence1118From 6 tokens (“Chunk size is a balance.”) to 24
By paragraph450One chunk per paragraph, 43 to 59 tokens

Fixed windows overlap by 45 characters, so the phrase “context tokens at query time. Small chunk” appears in two chunks. That duplication is the price of never losing a sentence at a cut.

Assumptions and limits

  • Characters, not tokens. Sizes are set in characters and tokens are a four-characters-per-token estimate.
  • Simple sentence detection. Abbreviations, decimals and ellipses end a “sentence” early, and text without punctuation never splits.
  • No word-level fallback. Recursive mode does not split a sentence longer than the limit, and it joins sentences without the whitespace between them, so its character counts run slightly low.
  • Overlap only in fixed mode. The other strategies never repeat text.
  • No structure awareness. Headings, tables, lists and code are treated as plain text.

How to use the result

  • Read the chunks, not just the counts. Each one should make sense alone; if it needs its neighbor to be understood, grow the size or split on structure.
  • Start near a few hundred tokens with 10 to 20% overlap, then tune against retrieval metrics on real questions.
  • Match strategy to content. Sentence or paragraph boundaries suit prose; fixed windows suit logs and long unpunctuated text.
  • Keep provenance. Store each chunk’s source and position so answers can cite it.

When to use it, and when not

Use it to pick a starting size and strategy on a real sample of your documents, to show a team why fixed windows cut words in half, and to catch oversized chunks before an embedding model truncates them. Paste a typical page, a long one and an awkward one, such as a document full of lists or code, and read every chunk.

Look elsewhere for documents whose structure carries meaning: Markdown with headings, HTML, tables, source code, PDFs with columns. A splitter that understands that structure keeps a table row with its header and a function in one piece. And no splitter, this one included, tells you whether retrieval works. Only an evaluation on real questions, checking that the right chunk comes back, settles the size.

Trade-offs and limits

Overlap costs more than its percentage. Windows advance by size − overlap, so on a long document stored text grows by 1 / (1 − overlap%) − 1: 11% extra at 10%, 18% at 15%, 25% at 20% and double at 50%. On the short sample the last window is cut short, so 15% overlap stores 891 characters for 801, 11% extra.

Chunk size sets three costs at once. For an illustrative corpus of 10 million characters, with 1,536-dimension float32 vectors at 6,144 bytes each:

Fixed, 15% overlapChunksVector storageTop-5 context
300 characters39,216241 MBabout 375 tokens
1,000 characters11,76572 MBabout 1,250 tokens

Small chunks mean more vectors and a sharper match for each, but every hit brings less surrounding text. Large chunks are cheaper to index and give the model more per hit, at the price of embeddings that average several topics together.

Recursive mode sits between: whole sentences, no repeats, uneven sizes. On the sample its three chunks run 224 to 284 characters against a 300 limit, so on average they use 88% of it; a chunk is closed early whenever the next sentence would not fit.

Common mistakes

  • Sizing in characters against a token limit. Four characters per token is an English-prose average. Code, URLs, numbers and many other languages produce more tokens per character, so a chunk that looks safe can pass an embedding model’s input limit and be silently truncated.
  • Chunks that lose their subject. A chunk that begins “It also supports streaming” no longer says what “it” is, so its embedding cannot match a question that names the product. Prepend the document title or section heading to each chunk before embedding.
  • Heavy overlap as a cure for bad boundaries. 50% overlap doubles storage and embedding cost and fills the top results with near-copies of one passage. Split on sentences or structure instead.
  • Tiny tail chunks. Fixed windows end wherever the text does, so the last chunk can be a few words that mostly repeat the one before. Merge a final chunk below a minimum size into its neighbor.
  • Changing the splitter without re-indexing. Chunks from two strategies, or two embedding models, in one index give scores that do not compare. Re-chunk and re-embed the whole corpus together.

Check yourself

On the 801-character sample, choose fixed size, 200 characters and 25% overlap. How many chunks, and what is odd about the last one?

Overlap is ⌊200 × 0.25⌋ = 50, so windows start every 150 characters: 0, 150, 300, 450, 600 and 750. The window at 600 ends at 800, one character short, so a sixth starts at 750. It holds 51 characters, “ws. Try a few here…”, and 50 of them repeat the chunk before: 13 tokens that add one full stop.

Fixed 300-character windows on a long document: how much more text do you embed at 15% overlap, and at 50%?

At 15% the overlap is 45 characters and the step 255, so every 255 new characters cost 300 stored: 300 / 255 = 1.18, 18% more. At 50% the step is 150 and the ratio is 2: every character is embedded twice.

In recursive mode with a 300-character limit, your text holds one 2,000-character sentence with no breaks. What chunk does it become?

One chunk of 2,000 characters, estimated at 500 tokens. Recursive mode never splits inside a sentence, so the limit is exceeded more than six times over. Add a word-level fallback or switch that content to fixed windows.

How many fixed chunks does a 10,000-character document make at 300 characters and 15% overlap?

The step is 255. Windows start at 0, 255, 510 and so on until one reaches the end: ⌈(10,000 − 300) / 255⌉ + 1 = 39 + 1 = 40 chunks. The last starts at 9,945 and holds only 55 characters. In all 11,755 characters are stored, 17.6% more than the document, close to the 18% long-document figure.

sample document: 801 characterschunk 1 · 0–300chunk 2 · 255–555chunk 3 · 510–801overlap 45overlap 45size 300 · overlap 15% = 45 · step 255
The default fixed-size split of the sample, to scale. Each 300-character window starts 255 characters after the last, so the 45 characters at each boundary, highlighted, are stored and embedded twice.

How it works

  • Fixed: cut every N characters, with an overlap percentage.
  • Recursive: pack whole sentences and paragraphs up to the size cap.
  • By sentence / paragraph: split on natural language structure.
  • Token counts are estimated (~4 chars/token), close enough to size chunks.

Frequently asked questions

What is chunking in RAG?

Chunking is splitting a source document into smaller pieces before embedding them for retrieval. Each chunk becomes one vector, and at query time the closest chunks are pasted into the prompt. Chunk size and boundaries directly affect retrieval quality: chunks that are too large dilute relevance and waste context tokens, while chunks that are too small lose the surrounding meaning a passage needs to be understood on its own.

What chunk size and overlap should I use?

A common starting point is a few hundred tokens per chunk with 10 to 20% overlap, but the right values depend on your content, your embedding model and the questions people ask. Short factual answers favor smaller chunks; questions that need a whole argument favor larger ones. Use this tool to see how your own text splits, then confirm the choice by measuring retrieval quality on real questions rather than by eye alone.

What is the difference between fixed and recursive chunking?

Fixed chunking cuts every N characters regardless of structure, so it can split a sentence or even a word in half. Recursive chunking prefers natural boundaries: in this tool it breaks the text at paragraph breaks and sentence ends, then packs whole sentences into each chunk until adding the next one would pass the size limit. Chunks stay readable, but their sizes vary, and a single sentence longer than the limit becomes an oversized chunk.

Why does overlap between chunks matter?

Overlap repeats a little text at the boundary of adjacent chunks, so a fact that straddles a split still appears whole in at least one of them. Without it, a sentence cut in half can become unretrievable from either side. The cost is duplication, and it is more than the percentage: windows advance by size minus overlap, so on a long document 15% overlap stores and embeds about 18% more text. In this tool overlap applies to fixed-size chunking, which is where blind cuts make it most necessary.

How are tokens estimated?

The tool divides each chunk’s trimmed character count by four and rounds, a common rule of thumb for English text with many tokenizers. It is close enough for sizing chunks, but real counts vary by model and language: code, numbers and non-English text usually produce more tokens per character. If an embedding model has a hard input limit, check your largest chunks with that model’s own tokenizer before indexing.