Recursive chunking, also called recursive character text splitting, is a method that divides a document into retrievable pieces by applying a ranked list of separators, starting with the coarsest boundary and falling back to finer ones only when a piece still exceeds the maximum chunk size. In the Retrieval & knowledge layer of artificial intelligence systems, it is the most widely used default for preparing text for embeddings and vector search in RAG pipelines.
The method aims to keep natural units of meaning together, such as paragraphs and sentences, while guaranteeing a predictable upper bound on chunk length. It sits between simple fixed-size chunking and more expensive semantic chunking, which is why many ingestion pipelines use it as their baseline.
How recursive chunking splits text
Recursive chunking works as a top-down splitting algorithm. The splitter tries the first separator in its list, typically a double newline that marks a paragraph break, and checks the length of every resulting piece against the chunk size limit.
Pieces that fit are kept, and pieces that are still too long are passed recursively to the next separator, such as a single newline, then a sentence-ending period followed by a space, then a space, and finally individual characters. A merge step then combines adjacent small pieces until each chunk approaches the target size, so the output does not consist of many tiny fragments.
Because the algorithm only descends to a finer separator when it must, coarse boundaries win whenever possible. A short paragraph therefore stays intact, while an unusually long paragraph is broken at sentence ends rather than at an arbitrary token position. This graceful degradation is the defining property of the method and the reason it handles mixed documents, which contain both short notes and long passages, better than a single fixed rule.
The following table shows a common default separator hierarchy for prose and what each level preserves.
| Order | Separator | Boundary it represents | Used when |
|---|---|---|---|
| 1 | Double newline | Paragraph | Always tried first |
| 2 | Single newline | Line or list item | A paragraph exceeds the limit |
| 3 | Period and space | Sentence | A line is still too long |
| 4 | Space | Word | A sentence exceeds the limit |
| 5 | Empty string | Character | A single token sequence is too long |
Most implementations also apply a chunk overlap, repeating a small window of text from the end of one chunk at the start of the next. Overlap reduces the risk that a fact split across a boundary becomes unretrievable from either chunk.
Key parameters and typical values
Three parameters control the behavior of a recursive splitter: chunk size, chunk overlap and the separator list. Their best values depend on the embedding model, the document type and the questions users ask.
| Parameter | Typical range | Effect of a higher value | Main risk |
|---|---|---|---|
| Chunk size | 256 to 1,024 tokens | More context per chunk | Diluted embeddings, weaker precision |
| Chunk overlap | 10 to 20 percent of size | Fewer facts cut at boundaries | Duplicate content and larger index |
| Separator list | 4 to 8 levels | Finer fallback control | Over-tuned rules for one format |
| Length function | Characters or tokens | Token counts match model limits | Character counts misjudge token use |
Measuring length in tokens rather than characters is the safer choice, because embedding models enforce token limits and the ratio of characters to tokens varies by language. Chunks that silently exceed the model limit are truncated during embedding, which removes content from the index without any error.
Recursive chunking compared with other chunking strategies
Recursive chunking is best understood as a structure-aware compromise. It respects document layout more than fixed-size splitting, yet it does not analyze meaning the way semantic or late chunking does.
| Strategy | Boundary logic | Cost | Typical weakness |
|---|---|---|---|
| Fixed-size chunking | Every N tokens | Very low | Cuts sentences and tables |
| Recursive chunking | Ranked separators with fallback | Low | Blind to topic shifts within a paragraph |
| Semantic chunking | Embedding similarity between sentences | Moderate | Sensitive to threshold choice |
| Late chunking | Token embeddings pooled after full-document encoding | Higher | Needs long-context embedding models |
| Parent document retrieval | Small chunks indexed, large parents returned | Moderate | More storage and logic |
In published comparisons, recursive chunking often performs close to semantic chunking on general prose at a fraction of the compute cost. Gains from more advanced methods tend to appear on long, loosely structured documents where topics change without paragraph breaks.
Adapting separators to document formats
The separator list is the main lever for format-specific splitting. Markdown documents benefit from heading markers as the first separators, so that each section stays together, while source code benefits from language-aware separators such as class and function definitions.
- Markdown and HTML: split on top-level headings first, then subheadings, then paragraphs.
- Source code: split on class and function boundaries before blank lines and statements.
- Legal and policy text: split on numbered clauses so that each obligation stays whole.
- Languages without spaces, such as Chinese or Japanese: add full-width punctuation as sentence separators.
Adding metadata to each chunk, such as the document title and the heading path, further improves retrieval because a chunk taken from the middle of a section otherwise loses its surrounding context.
Common mistakes and how to avoid them
Most problems with recursive chunking come from default settings applied without evaluation. Teams should measure retrieval quality with metrics such as recall@k on a set of real questions before and after changing any parameter.
| Symptom | Likely cause | Fix |
|---|---|---|
| Answers miss details split across chunks | No or tiny overlap | Add 10 to 20 percent overlap |
| Retrieved chunks are vague | Chunk size too large | Reduce size and test recall |
| Tables arrive as broken rows | Newline separators inside tables | Extract tables as separate units |
| Chunks exceed the model limit | Character-based length function | Count tokens with the model tokenizer |
The short version
AI search tools cannot read a whole manual at once. They need it cut into small pieces first. Recursive chunking is a careful way to cut.
It first tries to cut between paragraphs. If a paragraph is still too long, it cuts between sentences. Only as a last resort does it cut between words. The goal is pieces that are small but still make sense, like cutting a cake along its layers instead of at random.
Where it makes a difference
A support team at a software company builds an internal assistant over about 4,000 help articles written in Markdown. The first version uses fixed 500-token chunks, and agents complain that answers often cite half of a troubleshooting procedure, because step lists are cut in the middle.
The team switches to recursive chunking with Markdown headings as the first separators, a 512-token limit measured with the embedding tokenizer and a 64-token overlap. Each chunk also carries its article title and heading path as metadata. On a test set of 200 real support questions, recall@5 rises noticeably and complete procedures now appear in a single chunk, so agents spend less time opening the source articles.