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.
Direct answer
Switch the tool above to Split mode, paste the document or load one .md file, then choose 'Split by H1' or 'Split by H2'. Every line that starts with the chosen heading level begins a new part, and the heading stays at the top of its part. Each part gets a copy button and its own download button. There is no zip download, so parts are saved one at a time.
Open Merge & Split Markdown toolWhen to use this
- One handbook file has grown too long to edit comfortably.
- You want one page per section for a static site generator.
- A single spec needs to be shared as separate documents with separate owners.
Steps
- Open the tool and select the Split tab.
- Paste the document, or load a single .md file from disk.
- Choose 'By H1' or 'By H2' as the split mode.
- Review the parts list. Each part shows its heading and its character count.
- Copy a part, download it, or press Copy all to take everything at once.
Example conversion
# Handbook Welcome. ## Onboarding Day one checklist. ## Security Use the password manager.
Part 1 — Handbook # Handbook Welcome. Part 2 — Onboarding ## Onboarding Day one checklist. Part 3 — Security ## Security Use the password manager.
Common mistakes
- Text before the first heading becomes its own leading part. Move front matter or an intro under a heading if you do not want a stray part.
- A `#` inside a fenced code block is not a heading. Check parts that look wrong for code fences that contain shell comments.
- Splitting by H1 in a document with one H1 returns one part. Use H2 for a document with a single title.
FAQ
- Does the heading stay in the part?
- Yes. Each part starts with its own heading line, so a part is a valid standalone document.
- Can I download every part at once?
- No. A zip download would need a compression library, which this tool does not include. Use the per-part download buttons, or Copy all to take the full set as text.
- What happens to content before the first heading?
- It is kept as the first part rather than discarded, so nothing is lost.
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.
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.
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.