Markdown Table of Contents Generator (GitHub Heading Anchors)
Reads the headings of a Markdown document and writes a linked, nested table of contents.
Use the tool
Why this tool exists
A table of contents makes long READMEs easier to scan, but the anchors must match what GitHub generates: lowercase, punctuation removed, spaces turned into hyphens, and -1, -2 added to repeated headings.
This tool follows those rules, ignores headings inside fenced code, supports both # and underlined headings, strips links and emphasis from heading text, and lets you set the depth range and list marker. Other sites can use different slug rules, so check the links on your target platform.
How to use it
- Paste the Markdown.
- Set the shallowest and deepest heading level.
- Pick the list marker.
- Copy the list into your document.
Frequently asked questions
Do the links work outside GitHub?
Many renderers use the same slugs, but not all. Test on your platform.
Are code blocks ignored?
Yes. A # line inside a fenced block is not a heading.
What about repeated headings?
The second gets -1, the third -2, as on GitHub.