SEO · Content structure

Table of contents generator.

Paste HTML or Markdown and get a nested list of links to every heading. Missing ids are added, skipped heading levels are flagged. Runs in your browser; nothing is uploaded.

Advertisement

Input

Result

Paste some HTML or Markdown and press Generate.

Advertisement

How the list is built

HTML: every <h1> to <h6> element between your chosen levels becomes a link. Headings inside pre, code, script, style, textarea and comments are ignored. If a heading already has an id it is kept; otherwise one is made from the text (lower case, punctuation dropped, spaces to hyphens, -1, -2 on repeats) and shown in an annotated copy of your HTML.

Markdown: only ATX headings are read (lines starting with 1 to 6 # followed by a space). Setext headings (underlined with === or ---) and anything inside fenced code blocks are not. Anchors follow the common GitHub style; other renderers can generate different ids, so click a link after publishing.

Skipped levels: if an h4 follows an h2 there is no h3 in between. The list still nests it one step deeper, and you get a warning because skipped levels make the page outline harder to follow for screen reader users.

Sources: WHATWG HTML, heading elements; CommonMark 0.31.2, ATX headings and fenced code blocks; WCAG 2.2 technique H42, headings.

Advertisement

Frequently asked questions

Do I need to add ids to my headings myself?

No. Copy the annotated HTML this tool returns, which has an id added to each heading that lacked one, and paste it back into your page together with the list.

Will a table of contents help SEO?

It gives readers and crawlers jump links to sections, and search engines may show them as sitelinks under a result. This tool cannot promise either. Google decides that on its own.

Why is my h1 missing from the list?

The default range is h2 to h3. Set the lowest level to h1 to include it.

Is my content sent anywhere?

No. Parsing happens in your browser and nothing is stored or uploaded.

How does a table of contents link to a heading?

Each link has an href such as #setup, and the heading has a matching id, id="setup". MDN describes the id attribute as the way to identify a single element when linking with a fragment, and it must be unique in the document. The generator writes both halves: the list and, where missing, the ids.

What does the skipped-level warning mean?

It means a heading is more than one level deeper than the heading before it, such as an h4 straight after an h2. The list still nests it one step deeper so the links work, but MDN advises not skipping heading levels, since skipped levels make the outline harder to follow for screen-reader users.

Why are my Markdown links not working after I publish?

Markdown renderers create heading ids in slightly different ways. This tool uses GitHub-style ids, so a renderer with a different rule can produce different anchors. Click a link on the published page, and if it fails, copy the id your renderer produced or set an explicit id.

How a table of contents works on the web

A table of contents on a web page is a list of links that point at headings. Each link uses a fragment such as #setup, and the heading it points to carries a matching id="setup". MDN describes the purpose of the id attribute as identifying a single element when linking using a fragment identifier, and says the id must be unique in the whole document. MDN also notes that heading information can be used by user agents to construct a table of contents automatically. That is why two things have to be right at once: the list of links, and an id on every heading. This generator produces both.

Worked examples with real output

Markdown input

Paste this and press Generate with the default range (h2 to h3):

# Guide

## Setup

### Install

## Usage

#### Advanced flags

The tool finds the h2 and h3 headings, leaves out the h1 and the h4 because they are outside the range, and writes the HTML list <ul><li><a href="#setup">Setup</a> with Install nested under it, followed by Usage. It writes the same structure as a Markdown list too:

- [Setup](#setup)
  - [Install](#install)
- [Usage](#usage)

Change "Deepest level" to h4 and the list gains a nested Advanced flags link under Usage, together with a warning: h4 "Advanced flags" follows h2 "Usage" with no h3 between. That warning is the useful part. MDN's guidance on headings says not to skip heading levels, and a jump from h2 to h4 leaves a gap in the outline.

HTML input with a repeated heading

Given <h2>Setup</h2><h2>Setup</h2><h3 id="x">Install now</h3>, the tool keeps the existing x id, gives the first Setup the id setup and the second setup-1, so no two ids collide. It returns your HTML with the missing ids added, ready to paste back. Without that step the list would link to anchors that do not exist.

Punctuation and accents

Ids are generated from the heading text: lower case, punctuation dropped, spaces to hyphens. A heading "C++ & Café?" becomes c--café in the output, with the accented letter kept. Browsers handle that, but if you would rather have a short ASCII id, write your own id on the heading first; the tool keeps ids it finds.

Choosing a range

Markdown details

Only ATX headings are read, which CommonMark defines as lines that begin with an opening sequence of one to six # characters followed by spaces. Setext headings (underlined with === or ---) and anything inside fenced code blocks are not. The anchors follow the common GitHub-style pattern, but Markdown renderers do not agree, so the tool tells you to click a link after you publish. Always test once in the system you actually use.

Common mistakes

Who this is for, and what it does not cover

It suits long articles, documentation pages, README files and CMS posts where a theme or plugin does not already generate a table. It does not add a "back to top" link, smooth scrolling, collapsible sections, or schema markup, and it does not check that the finished anchors work in your CMS. To audit the heading order itself, use the H1 & Heading Checker; to give a heading a clean id, the URL Slug Generator makes lowercase hyphenated text; and to compare the outline before and after an edit, see the Heading Outline Diff.

Sources

Each source was opened and checked against the statements above in October 2026. Standards and vendor documentation change; follow the links for the current text.

Text processing only

This tool reads heading text and builds links. It does not check that the resulting anchors work in your site, CMS or Markdown renderer, so test a link after you publish.