CommonMark and GitHub tables to clean, sanitized HTML
Markdown TOC Generator
Add a clickable table of contents to a README or docs page whose links match the anchors GitHub creates.
Loading tool…
How to use markdown toc generator
Paste Markdown or open a .md file.
Choose the heading levels to include and a bullet or numbered list.
Copy the TOC on its own, or switch to Document with TOC to get the file with the list inserted.
Download the result. Running it again later replaces the list between the toc markers.
What this tool does
- Builds anchors with GitHub's rules: lower case, punctuation removed, spaces turned into hyphens.
- Numbers repeated headings the way GitHub does: the second #setup becomes #setup-1, the third #setup-2.
- Finds headings with the real parser, so # lines inside code blocks are ignored and underlined headings count.
- Nests the list by heading level and keeps numbered lists correctly indented past item 9.
How the result is verified
The document is also rendered with heading ids, and every link in the TOC is checked against those ids. Any anchor that does not match is listed.
Frequently asked questions
Why do my anchors have -1 at the end?
Two headings have the same text. GitHub keeps the first anchor as it is and adds -1, -2 and so on to later ones, and this tool does the same so the links land on the right heading.
Will the TOC update itself?
No. Markdown files are static. Paste the updated file in again and the list between the <!-- toc --> and <!-- tocstop --> markers is replaced.
Is my data uploaded to a server?
No. Everything you drop, paste or type is processed by code running in this browser tab. You can check it yourself: open your browser's developer tools, watch the Network panel, and use the tool. No request carries your data.
Related tools
Consistent headings, bullets, emphasis and spacing, output unchanged
Every link, image and reference in a Markdown file, with line numbers
A split Markdown editor and preview for README files, notes, documentation, and messages, processed locally.