Before and after
Example: unsorted markdown headers become alphabetically ordered. Content under each header stays with its header.
Before
# Zebra
Section about Zebra.
# Apple
Section about Apple.
# Mango
Section about Mango.
After (sorted)
# Apple
Section about Apple.
# Mango
Section about Mango.
# Zebra
Section about Zebra.
Try it with your markdown
Questions and answers
What is a markdown header sorter?
A markdown header sorter is a tool that sorts markdown sections alphabetically by their headings. This one works online in your browser: you paste markdown, choose a header level (# to ######) or sort all levels, and get reordered output. No install needed.
How do I sort markdown headers alphabetically?
Paste your markdown into the input box, ensure each header has a blank line above and below it, then choose "All headers" to sort every level or pick a single level (#, ##, etc.). The result updates live; use "Copy result" to use the sorted markdown elsewhere.
Do I need to install anything?
No. This markdown header sorter runs entirely in the browser. For use in Node.js you can use the open-source script from the GitHub repo.
Why do headers need blank lines above and below?
The tool detects a line as a markdown header only when it has a newline above and below it. That follows common markdown style and avoids misdetecting # in the middle of a sentence. See the format requirements on this page for correct vs incorrect examples.
Can I sort only one header level (e.g. ##)?
Yes. Use the level pills to choose "All headers" (recursive sort) or a single level: #, ##, ###, ####, #####, or ######. Sorting only ## reorders level-2 sections alphabetically and leaves # and ### etc. unchanged.
Is the markdown header sorter free?
Yes. The tool is free to use and open source. No account or sign-up required.