BYTETOOLS

Table of Contents Generator

Paste Markdown or HTML and get a nested, linked table of contents with GitHub-style anchor slugs — output as Markdown, an HTML list or plain text.

Anchors are slugified GitHub-style (lowercase, punctuation removed, spaces → hyphens, duplicate headings get -1, -2 …). HTML headings with an explicit id keep that id.

What is the Table of Contents Generator?

The Table of Contents Generator extracts every heading from a pasted Markdown or HTML document and builds a nested, clickable TOC.

  • GitHub-style anchor slugs with -1/-2 duplicate handling
  • Markdown and HTML input with auto-detection
  • Skips fenced code blocks when scanning Markdown
  • Configurable heading level range (H1–H6)
  • Markdown, nested HTML <ul> or indented plain-text output
  • Keeps explicit id attributes on HTML headings

How to use the Table of Contents Generator

  1. 1

    Paste your Markdown or HTML document (auto-detected, or set the format manually).

  2. 2

    Choose the shallowest and deepest heading levels to include.

  3. 3

    Pick the output format: Markdown list, HTML <ul> or plain text.

  4. 4

    Copy the generated TOC or download it as a file.

About the Table of Contents Generator

The Table of Contents Generator extracts every heading from a pasted Markdown or HTML document and builds a nested, clickable TOC. Anchors are slugified exactly the way GitHub does it — lowercased, punctuation stripped, spaces turned into hyphens, and duplicate headings deduplicated with -1, -2 suffixes — so the links work in READMEs out of the box.

Choose which heading levels to include (for example H2–H4 only), then export the TOC as a Markdown bullet list, a nested HTML <ul> with escaped anchor links, or a plain-text indented outline. Markdown parsing skips fenced code blocks so a # inside a code sample is never mistaken for a heading, and HTML headings that already carry an id keep it.

It is ideal for long READMEs, documentation pages, blog posts and wiki articles where a navigable outline saves readers real time. Everything runs 100% locally in your browser — your document is never uploaded to any server, private drafts stay private, and the generator keeps working with no internet connection at all.

Frequently asked questions

How do I make a table of contents in Markdown?

Paste your document here and copy the generated bullet list of [Heading](#anchor) links to the top of your file. GitHub, GitLab and most Markdown renderers automatically give each heading a matching anchor, so the links just work.

How does GitHub generate heading anchors?

It lowercases the heading, removes punctuation, and replaces spaces with hyphens; a second identical heading gets a -1 suffix, the third -2, and so on. This tool applies the same algorithm so your TOC matches GitHub exactly.

Can I include only certain heading levels?

Yes. Set the shallowest and deepest levels — a common choice is H2 to H4, which skips the page title and very deep subsections. The nesting in the output is re-based on the shallowest level you keep.

Does it work with HTML pages?

Yes — paste the HTML source and it reads every h1–h6 tag. Headings that already have an id attribute keep that id in the TOC links; the rest get GitHub-style slugs generated from their text.

Will a # inside a code block become a heading?

No. The Markdown parser tracks fenced code blocks (``` or ~~~) and ignores everything inside them, so shell comments and Python code never pollute your table of contents.

Related tools