DevTools Logo

RAG Chunking & Overlap Visualizer

RAG Chunking & Overlap Visualizer

Explore document chunks and overlap locally with exact character offsets

Source text

About

Inspect colored chunks, lengths, offsets, overlap percentages, and approximate token counts using the chars divided by four rule. No text leaves your browser.

Examples

Sliding window with overlap

Input
chunkRAGText("abcdefghij", { strategy: "sliding", size: 6, overlap: 2 })
Output
["abcdef" 0-6, "efghij" 4-10] overlap 2 chars (33.33%)

Stride is size minus overlap, so the second chunk starts at 4 with 2 shared characters.

Sentence grouping

Input
chunkRAGText("One sentence. Two sentence! Three?", { strategy: "sentence", size: 30 })
Output
["One sentence. Two sentence!", " Three?"]

Complete sentences are grouped up to size without ever splitting mid-sentence.

About this tool

RAG Chunking Visualizer splits long text for retrieval pipelines with chunkRAGText(text, options) (also exported as visualizeRAGChunks): fixed and sliding strategies cut by character size with exact start/end offsets per chunk, sentence groups whole sentences up to size, and paragraph splits at blank lines while preserving source offsets.

Sliding windows advance by a stride of size minus overlap, and each chunk records overlapChars, overlapPercentage, and estimatedTokens under the explicit chars/4 rule. Overlap is clamped to size - 1, so requesting overlap >= size yields maximum overlap with stride 1 instead of stalling, and empty input returns zero chunks deterministically.

Everything is deterministic and browser-safe: identical inputs always produce identical chunks, token counts are clearly approximate, and no text leaves the browser.

How to use this tool

  1. Paste the source text

    Drop the document into the input — empty text yields zero chunks with zero estimated tokens.

  2. Pick a strategy, size, and overlap

    Use fixed for even cuts, sliding with overlap for context windows, sentence to keep sentences intact, or paragraph to split at blank lines.

  3. Check offsets and overlap

    Verify each chunk's start/end slice matches the source and that sliding chunks satisfy next.start == prev.end - overlap.

  4. Copy chunk boundaries

    Use the visualized chunks and chars/4 token estimates to tune size and overlap for your retriever.

Use cases

Tuning retriever windows

Preview how chunk size and overlap change coverage before indexing into a vector store.

Debugging offset maps

Confirm chunk start/end offsets round-trip to exact source slices for citation highlighting.

Comparing split strategies

Contrast fixed, sliding, sentence, and paragraph chunking on the same document.

Common mistakes

Mistake:Expecting overlap >= size to throw.

Fix:Overlap clamps to size - 1 — requesting more simply yields stride 1 with maximum overlap, not an error.

Mistake:Treating estimatedTokens as a real tokenizer count.

Fix:Tokens are Math.ceil(chars / 4), an explicitly approximate rule — use a model tokenizer for exact budgets.

Mistake:Assuming sentence chunks split at exactly size.

Fix:Sentence mode groups whole sentences up to size, so chunks may run shorter or spill past size to keep a sentence intact.

Frequently asked questions

What does this tool do?

It splits text with chunkRAGText (alias visualizeRAGChunks): fixed and sliding cut by character size with exact offsets, sentence groups whole sentences, and paragraph splits at blank lines — each chunk carrying overlapChars, overlapPercentage, and chars/4 token estimates.

What happens when overlap is >= size?

Nothing breaks: overlap clamps to size - 1, so sliding advances with stride 1 at maximum overlap instead of stalling or throwing.

Is my text uploaded or stored?

No. Chunking is deterministic and 100% client-side — your documents never leave the browser.

Are token counts exact?

No, they are explicitly approximate (Math.ceil(chars / 4)). Use a model tokenizer when you need exact budgets.

References & standards