Markdown table of contents generator

Automatically generate a table of contents from the headings (#, ##, ###...) of a Markdown document.

Example:

How it works

Useful for automatically adding a clickable table of contents at the top of a long README, a technical blog post, or Markdown documentation: paste the full document, click "Generate table of contents", then copy the resulting bullet list to the top of your file. Each entry points to a `#slugified-heading` anchor matching the heading, which works directly on GitHub, GitLab, and most Markdown rendering engines.

How are headings detected?

The tool scans line by line for lines starting with one or more `#` followed by a space (the standard ATX style: `# Title`, `## Subtitle`, etc.). The alternative Markdown style where a heading is underlined with `===` or `---` on the following line is not recognized; if you use this style, convert your headings to `#` notation first.

How are the link anchors generated?

Each heading is "slugified": converted to lowercase, punctuation is removed, and spaces are replaced with hyphens. For example, "Step 1: Installation!" becomes the anchor `step-1-installation`. If two identical headings generate the same anchor, most Markdown engines automatically add a numeric suffix (`-1`, `-2`...) to the second one — check the final rendering if your document contains duplicate headings.

Table of contents generation runs 100% locally in your browser via WebAssembly: your document content never leaves your device.