Skip to content
hateitall

Markdown TOC Generator

Add a clickable table of contents to a README or docs page whose links match the anchors GitHub creates.

Processed locallyIn: Markdown, MDOut: Markdown

Loading tool…

How to use markdown toc generator

  1. Paste Markdown or open a .md file.

  2. Choose the heading levels to include and a bullet or numbered list.

  3. Copy the TOC on its own, or switch to Document with TOC to get the file with the list inserted.

  4. 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.

CommonMark and GitHub tables to clean, sanitized HTML

Markdown · MD · Text→ HTMLLight on device

Consistent headings, bullets, emphasis and spacing, output unchanged

Markdown · MD→ MarkdownLight on device

Every link, image and reference in a Markdown file, with line numbers

Markdown · MD→ ListLight on device

A split Markdown editor and preview for README files, notes, documentation, and messages, processed locally.

Markdown · MD · TXT→ Markdown (.md)Light on device