Chunk a Markdown File for AI Context Windows
Split a long document into size-limited parts so each chunk fits a model context window or a RAG index entry. Size is set in characters, with an approximate token count shown.
Direct answer
Use Split mode and choose 'By size'. Set a target size in characters. The tool breaks the document at paragraph boundaries where it can, so a chunk does not end mid-sentence, and shows each part's character count with an approximate token estimate of about four characters per token. Copy each chunk into a chat, or paste them one at a time into a RAG ingestion step.
Open Merge & Split Markdown toolWhen to use this
- A document is longer than the model's context window.
- You are building a retrieval index and need consistent chunk sizes.
- Long pastes get truncated in a chat interface.
Steps
- Open the tool and select the Split tab.
- Paste the document or load a .md file.
- Choose 'By size' and set the character target, for example 6000.
- Check the part list: each row shows the character count and the estimated tokens.
- Copy or download each part in order.
Example conversion
A 20,000 character architecture document, split at a 6,000 character target.
Part 1 — 5,842 chars (~1,460 tokens) Part 2 — 5,910 chars (~1,478 tokens) Part 3 — 5,733 chars (~1,433 tokens) Part 4 — 2,515 chars (~629 tokens)
Common mistakes
- The token number is an estimate from character count, not a real tokenizer result. Leave headroom before a hard model limit.
- Size splitting ignores document structure beyond paragraph breaks, so a heading and its body can land in different chunks. Split by heading first if section boundaries matter more than even sizes.
- Very small targets produce many parts and each one loses surrounding context. Prefer the largest size the model accepts.
FAQ
- How accurate is the token estimate?
- It uses roughly four characters per token, which is close for English prose and less accurate for code, other languages, or heavy punctuation. Treat it as a guide, not a limit.
- Does the tool overlap chunks?
- No. Parts do not overlap. If your retrieval setup needs overlap, add it after copying the parts.
- Is the document sent to a server?
- No. Splitting runs in your browser. This matters for internal documents, which is a common reason people chunk text.
Related merge and split guides
How to Combine Multiple Markdown Files Into One
Select several .md files, put them in the order you want, and join them with a horizontal rule or a filename heading between each one. Everything runs in the browser.
How to Split a Long Markdown Document by Heading
Paste one large Markdown document, choose H1 or H2 as the break point, and get one part per section with its own copy and download button.
Merge a Docs Folder Into a Single Markdown File
Select every file in a docs folder, order them, and join them into one document with filename headings so each source stays identifiable.
Split a Book Manuscript Into Chapter Files
A manuscript that uses one H1 per chapter can be split into one file per chapter, each downloadable on its own.