TokenPad
Optimisation

Text Splitter for RAG and Embeddings

Chunk text by real tokens, with overlap, without cutting mid-sentence.

Source text
ChunksExact
0chunks
Total tokens0
Average size

Overlap duplicates roughly 40 tokens between neighbours, so the total above exceeds the source document. That duplication is the point: a sentence on a boundary appears whole in at least one chunk.

Output

    What this tool tells you

    Retrieval-augmented generation lives or dies on how the source material was divided. This splits text into chunks measured in real tokens rather than characters, with configurable overlap, and without cutting through the middle of a sentence.

    Every chunk shows its exact token count, because the limit your embedding model enforces is denominated in tokens and a character-based splitter produces chunks of wildly varying token length. Some of those will quietly exceed the limit and be truncated, and truncation in an embedding pipeline is silent — the vector is simply wrong and nothing tells you.

    Choosing a chunk size

    For most retrieval work, 200 to 500 tokens. The trade-off is precision against interpretability:

    • Too small and a chunk loses the context that makes it meaningful. A sentence referring to "the second approach" is useless without the paragraph that introduced the first. Retrieval succeeds and the answer is still wrong.
    • Too large and the embedding dilutes. One relevant sentence among two hundred irrelevant ones produces a vector that sits nowhere near the query. Retrieval simply misses.

    Start at 300 and let the failure mode tell you which way to move. If the right passage is never retrieved, go smaller. If it is retrieved but the answer is incoherent, go larger.

    Why overlap is not optional

    Meaning does not respect chunk boundaries. A sentence split across two chunks appears complete in neither, so neither embedding represents it and it becomes effectively unsearchable. Ten to twenty percent overlap means any given sentence appears whole in at least one chunk.

    The cost is duplicated storage and a slightly larger index. Compared to a retrieval failure that silently returns the wrong passage, it is cheap. The readout above shows the duplication explicitly, so you can see what you are trading.

    Sentence, paragraph or exact token

    Sentence is the sensible default. Chunks stay close to the target size and never begin mid-clause.

    Paragraph suits documentation and articles where a paragraph is a self-contained idea. Chunk sizes vary more, and a single long paragraph can exceed the ceiling — the tool flags that rather than silently splitting it.

    Exact token produces perfectly uniform chunks and cuts wherever it lands, including mid-word. Useful when you need deterministic sizing for a fixed-shape index, and a poor default for anything a model will read back.

    What happens after chunking

    Chunks get embedded, stored, and later retrieved into a prompt — which brings back the constraint everything else here is about. If you retrieve eight chunks of 400 tokens, that is 3,200 tokens of context on every single request, billed every time. Check what your retrieved set costs in the cost calculator, and confirm it fits alongside your system prompt in the context window calculator.

    Retrieving fewer, better chunks beats retrieving more, and it is cheaper on both the embedding and the generation side. That is the whole argument for spending time on chunk quality rather than raising the retrieval count until something works.

    A note on the counts

    Chunking here uses o200k_base, the current OpenAI encoding, so the counts are exact for OpenAI models and close for most others. Embedding models from other providers tokenize differently — leave a margin below their stated limit rather than filling it exactly. If you need the source document measured against a specific model first, use the token counter.

    Frequently asked questions

    What chunk size should I use?
    For most retrieval work, 200 to 500 tokens per chunk. Smaller chunks retrieve more precisely but lose the surrounding context that makes a passage interpretable; larger chunks carry context but dilute the embedding, so a single relevant sentence gets buried among irrelevant ones. Start at 300 and adjust based on whether your retrieval misses or your answers drift.
    Why do chunks need to overlap?
    Because meaning does not respect chunk boundaries. A sentence split across two chunks appears complete in neither, and neither embedding represents it. An overlap of ten to twenty percent means any given sentence appears whole in at least one chunk. The cost is duplicated storage, which is cheap compared to a retrieval failure.
    Why split on tokens rather than characters?
    Because the embedding model’s limit is denominated in tokens. A 1,000-character chunk of English prose is roughly 250 tokens, but the same 1,000 characters of JSON might be 400. Character-based splitting produces chunks of wildly varying token length, and some of them will silently exceed the model limit and be truncated.
    Should chunks respect sentence boundaries?
    Almost always yes. A chunk that starts mid-clause embeds poorly and reads badly when it is later shown to the model as retrieved context. The boundary options here find the nearest sentence or paragraph break rather than cutting at an exact token index, which costs a little uniformity and gains a lot of quality.

    More optimisation tools