About Markdown Table of Contents Generator
Paste a README or any long Markdown document and get a ready-made table of contents to paste back at the top. Each entry links to its heading using the same anchor ids GitHub generates, including the numbered ids it gives repeated headings, so the links work on GitHub and on any renderer that follows the same rules.
Choose which heading levels to include, bullets or numbers, and the indent. Headings inside code blocks, HTML comments and front matter are ignored.
How it works
- The document is parsed as GitHub-flavoured Markdown, so both # headings and underlined (=== and ---) headings are found, and anything in code blocks or HTML is skipped.
- Each heading’s visible text becomes its anchor: lower-cased, with punctuation and symbols removed and each space turned into a hyphen. A repeated heading gets -1, -2 and so on, counted across the whole document.
- Headings in the chosen range are listed in order. A heading that skips a level (H2 straight to H4) is nested one step, so the list never jumps two indents at once.
Questions
Why does an anchor have two hyphens in a row?
Because GitHub does the same. "Units & measures" loses the ampersand but keeps both spaces, which become hyphens: #units--measures. Matching that exactly is what makes the links work.
Are headings inside quotes or lists included?
No, only headings at the top level of the document are listed. They still count when repeated headings are numbered, as they do on GitHub.
Will the links work outside GitHub?
Wherever the renderer uses GitHub’s rules for heading ids, which many do. Some site generators use their own rules; turn off links if yours does, and add anchors by hand.
Does it insert the table into my document?
No. It produces the list on its own, for you to copy or download and paste where you want it.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.