Table of contents generator

Updated

Paste a markdown document and get a linked table of contents built from its headings — with anchor slugs generated exactly the way GitHub does it, so every link works in your README. Nothing leaves your browser.

Generated TOC
- [Getting started](#getting-started)
  - [Prerequisites](#prerequisites)
  - [Installation](#installation)
- [Configuration](#configuration)
  - [Environment variables](#environment-variables)
- [Deployment](#deployment)
- [FAQ](#faq)

How do the anchor links work?

Every heading in rendered markdown gets an HTML id: the text lowercased, spaces turned into hyphens, punctuation dropped, and a -1, -2… suffix added to duplicates. This tool uses github-slugger — the same algorithm GitHub uses — so ## Getting Started! correctly becomes #getting-started. Headings inside code fences are ignored, and markdown formatting inside headings is stripped from the link text.

Where should the TOC go?

Convention: directly under the H1 title, headed “Table of contents” — which is exactly what the Insert into document button does. For long READMEs, limiting depth to H2–H3 keeps it scannable; go deeper only for reference docs. GitHub also auto-generates a TOC in the file header menu, but an inline one still helps readers on npm, crates.io, and anywhere else the README is mirrored. See how markdown links work for the anchor syntax itself, and ask your AI agent to publish the finished doc to Docs MD when it is done.

Questions about TOC generator

Will the links work on GitHub?

Yes. Anchors are built with github-slugger, the same algorithm GitHub uses for heading ids: lowercase, spaces to hyphens, punctuation dropped, and -1, -2… added to duplicate headings. The links also work on GitLab, npm and most static-site generators that follow the same rules.

Which heading levels should the TOC include?

You choose the depth. For a README, H2–H3 keeps the list scannable; include H4 and deeper only for long reference documents. The document title (H1) is left out because the TOC sits directly under it.

Are headings inside code blocks counted?

No. Lines that start with # inside a fenced code block are code, not headings, and are skipped. Markdown formatting inside a heading (bold, inline code, links) is stripped from the link text but kept in the anchor the way GitHub computes it.

Is my document uploaded anywhere?

No. The headings are parsed in your browser; the text never leaves your machine. The Insert into document button edits your pasted copy locally so you can copy the finished file back out.

More markdown tools