Text tools

Markdown TOC Generator

Markdown Table of Contents Generator

Generate a table of contents for a README or Markdown document with GitHub-compatible anchor links.

About this tool

About Markdown TOC Generator

A long README or documentation page is much easier to use with a table of contents at the top, but writing one by hand means working out every anchor and keeping it in sync. Paste your Markdown and this generator lists the headings as a nested list of links, using the same anchor rules as GitHub: lower case, punctuation removed, spaces turned into hyphens and -1, -2 added to repeated headings. Headings inside code blocks are ignored, and both # headings and underlined ones are found. Choose which levels to include (H2 to H3 is a good default), bullets or numbered entries, two- or four-space indentation, and whether to skip the document title. Plain-text entries are available for platforms without anchor support. Switch the output to Document with TOC to insert the table between <!-- toc --> and <!-- tocstop --> markers after your title and intro; generating again replaces the old table instead of adding a second one. Everything runs locally.

Built and maintained by Abhi JainUpdated

How to Generate a Markdown TOC

  1. 1

    Paste your Markdown

    Paste a README or document into the Markdown box, or open a .md file.

  2. 2

    Set the levels and style

    Choose From and To heading levels, Bullets or Numbers, and tick Anchor links and Skip the title (H1).

  3. 3

    Copy or insert

    Copy the Table of contents, or choose Document with TOC and download the whole file with the table inserted.

Markdown TOC Generator: questions and answers

Will the links work on GitHub?

Yes. Anchors are generated with GitHub's rules, including duplicates (#setup, #setup-1). GitLab and most static-site generators use the same scheme. If a platform differs, untick Anchor links for a plain list.

Why is a heading missing?

Check it has a space after the hashes (## Install, not ##Install), that its level is within From and To, and that it isn't inside a code block. The title H1 is skipped when Skip the title is ticked.

How do I update the TOC later?

Paste the document that already has the <!-- toc --> markers and choose Document with TOC: the old table between the markers is replaced. Some editors' TOC extensions recognise the same markers.

Can I check that my anchor links work?

Yes: the Markdown Link Extractor flags links to #anchors that don't match any heading.