Markdown TOC Generator
Generate a nested table of contents from your Markdown headings, with GitHub-compatible anchor links.
Paste Markdown above to build its table of contents.
How it works
This generator scans your Markdown for headings — both ## ATX style and the
underlined Setext style — and turns them into a nested table of contents you can paste
straight into your README. Headings inside fenced code blocks (``` or ~~~) and inside YAML
front matter are ignored, so a # comment in a shell snippet never ends up in the
list. Choose which heading levels to include, whether you want bullets or a numbered list,
and how deep each level is indented; the TOC is rebuilt instantly on every change.
Anchor links use the same slug rules GitHub applies: the heading text is lowercased,
formatting such as **bold**, backticks and links is stripped, punctuation is
removed, spaces become hyphens, and repeated headings get -1, -2
suffixes so every link is unique. That makes the output work as-is on GitHub, GitLab and most
static-site generators. Everything runs as JavaScript in your own browser — your document is
never uploaded, logged or stored, so it is safe for private repos and internal docs.
Frequently asked questions
How do I add a table of contents to a GitHub README?
Paste your README into the box, pick which heading levels to include (H2–H3 suits most projects), then click Copy TOC and paste the list near the top of your README — usually right under the intro paragraph. The links use GitHub's own anchor slugs, so they jump to the right section as soon as you push the file. GitHub does not build a TOC for you inside the README itself, which is why a generated list like this is still the standard approach.
Does it handle code blocks, duplicate headings and punctuation correctly?
Yes. Lines inside fenced code blocks (``` or ~~~) and inside YAML front matter are skipped, so a shell comment like "# install" never becomes a TOC entry. Anchor slugs follow GitHub's rules: the text is lowercased, bold, italics, backticks and inline links are stripped, punctuation is dropped, spaces become hyphens, and a heading that appears twice gets -1, -2 suffixes so every link stays unique. Underlined Setext headings are recognised too.
Is my document uploaded anywhere?
No. The Markdown is parsed and the list is built entirely by JavaScript running in your browser tab — nothing is sent to a server, logged or stored, and the tool keeps working offline once the page has loaded. That makes it safe for private repositories, internal documentation and unpublished drafts, with no account, no ads and no watermark.