Markdown TOC Generator

Paste a Markdown document; get a table of contents listing every heading with GitHub-compatible anchor links. Configure max depth and whether to include the document's H1.

How to use the Markdown TOC Generator

Paste Markdown. The generator finds # through ###### headings and produces a nested list. Anchor slugs follow GitHub's algorithm: lowercase, hyphens for spaces, strip punctuation. Drop the result into the top of your README.

A table of contents from your headings

A long Markdown document — a README, a wiki page, a spec — is far easier to navigate with a table of contents linking to each section. Building one by hand means copying every heading and working out the anchor link the platform will assign, then keeping it all in sync as the document changes.

This generator reads the headings from # through ###### and produces a nested list, with each entry linking to its section. The anchor slugs follow GitHub's rule — lowercase the text, replace spaces with hyphens, strip punctuation — so the links work when the file is viewed on GitHub. You control the maximum depth and whether the document's H1 is included.

Common use cases

  • README navigation — add a clickable contents list to the top of a project README.
  • Long documentation — give a multi-section page jump links to each heading.
  • Wikis and specs — generate the contents block for a lengthy reference document.
  • Controlling depth — include only H2s, or go down to H6, depending on how detailed the list should be.
  • Numbered or bulleted — choose the list style that fits the document.

Frequently asked questions

How are the anchor links generated?

They follow GitHub's slug algorithm: lowercase the heading, replace spaces with hyphens, and strip most punctuation. That matches the anchors GitHub assigns so the links resolve when viewed there.

How is this different from the anchor generator?

This builds the whole nested contents list for a document. The Markdown anchor generator produces the slug for a single heading — useful when you want to link to one section by hand.

Can I limit how deep the list goes?

Yes. Set the maximum depth from H2 down to H6, so a contents list can stay high-level or expand to every subsection.

Should the H1 be included?

Usually not — the H1 is the document title, and a contents list of one top entry is redundant. A toggle lets you include it when you need to.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: