Markdown Table of Contents Generator
Generate a table of contents for a Markdown file with GitHub-compatible anchor links, a chosen range of heading levels and nested bullets.
Free · No sign-up · Your inputs stay in your browser
Input
Generate a table of contents for Markdown
Output
Table of contents
6 entries
Anchors follow GitHub's rules: lowercase, punctuation removed, spaces to hyphens, and -1, -2 appended to repeated headings, so the links work in a README. Headings inside fenced code blocks are skipped.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
GitHub's anchor rules
GitHub creates an id for every heading from its text. Two headings with the same text get section and section-1, which is the detail most hand-written tables of contents get wrong. GitLab and many static site generators follow similar rules, but check yours if anchors use a different slug function.
Do you need one
GitHub already shows an outline button for README files, and most documentation themes build a sidebar from headings. A written table of contents still helps in long files viewed elsewhere, such as on npm or Packagist, or printed.