Table of Contents Generator
This generator reads the headings in your article, gives each one a unique id, and builds a nested list of jump links that points at them. Paste HTML or Markdown, choose which heading levels to include, and copy a ready nav block, a Markdown list, or your HTML with the anchor ids already added.
| Input | Headings read from | Outputs |
|---|---|---|
| HTML | <h1> to <h6> elements | Nav HTML, Markdown list, article with ids added |
| Markdown | Lines starting with # to ###### | Nav HTML, Markdown list |
| Existing ids | id="..." or {#custom-id} | Kept as they are |
| Repeated headings | Same text twice | Second id gets -1, then -2 |
Updated
Long guides are easier to scan and share when readers can jump to a section. The links also give each part of the page its own address, so you can send someone straight to the paragraph they need.
Generate a table of contents
Paste an article as HTML or Markdown. The headings are read, given unique anchor ids, nested by level and turned into an HTML nav, a Markdown list and, for HTML input, a copy of your article with the missing ids added.
Sticky contents sidebar
A two-column layout where the contents stay in view and headings clear a fixed header.
Sticky nav plus heading offset
The frame is short, so scroll inside it: the contents column stays pinned while the article moves.
<style>
.layout { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; }
.toc { position: sticky; top: 0.5rem; align-self: start; font-size: 14px; }
.toc ul { margin: 0; padding-left: 1rem; }
h2 { scroll-margin-top: 4rem; margin: 0 0 4px; }
section { min-height: 160px; }
</style>
<div class="layout">
<nav class="toc" aria-label="Contents">
<ul>
<li><a href="#budget">Set a budget</a></li>
<li><a href="#layout">Choose a layout</a></li>
<li><a href="#people">Hire people</a></li>
</ul>
</nav>
<article>
<section><h2 id="budget">Set a budget</h2><p>Plan for materials, labour and a buffer.</p></section>
<section><h2 id="layout">Choose a layout</h2><p>Galley, L-shaped or island.</p></section>
<section><h2 id="people">Hire people</h2><p>Get three written quotes.</p></section>
</article>
</div>
How the anchor ids are made
Each heading's text is lower-cased, punctuation is dropped, and spaces become hyphens, so Choose a layout becomes choose-a-layout. Accented letters and non-Latin scripts are kept rather than stripped.
An id must be unique in the document and must not contain spaces. When the same heading text appears twice, the second copy gets -1 added, the third -2, so every link has exactly one target.
Markdown platforms make their own heading ids, and their rules differ slightly. If you publish Markdown somewhere that already adds ids, check one link after publishing; for HTML you control, use the article output so the ids match exactly.
Placing the contents block
Put the contents list after the introduction, not above it, so readers first learn what the page is about. On wide screens a sticky sidebar keeps it in reach while they scroll.
If your site has a fixed header, a jump link will hide the heading underneath it. The scroll-margin-top property adds space above the target when the browser scrolls to it, which fixes this without JavaScript.
How it works
- Paste your article. The tool detects HTML when it sees heading tags; otherwise it reads Markdown headings and skips fenced code blocks.
- Choose the shallowest and deepest heading level to include. Most articles list H2 and H3 only.
- Pick a bulleted or numbered list and set the label screen readers announce for the nav.
- Copy the contents block. For HTML input, also copy the article with ids so every link has its target.
Tips
- Keep headings short and specific; they become both link text and the anchor in the address bar.
- Avoid skipping levels (an H4 straight under an H2). The tool nests it anyway, but screen reader users navigate by heading level.
- Changing a heading changes its id, which breaks links people have shared. Set a fixed id if a section is linked from elsewhere.
- Do not put the page's H1 in the contents list; the reader is already at the top.
Frequently asked questions
How do I make a clickable table of contents in HTML?
Give each heading an id, then link to it with a hash: <a href="#set-a-budget">Set a budget</a> jumps to the element with id="set-a-budget". Wrap the links in a nav element with a list inside. This tool writes both the ids and the list.
Why does my jump link land behind the header?
A fixed or sticky header covers the top of the window, and the browser scrolls the heading to that top edge. Add scroll-margin-top to headings, a little larger than the header height, and the heading stops below it.
Can I make the table of contents sticky?
Yes. Put the nav in a sidebar column and give it position: sticky with a top value. It scrolls normally until it reaches that offset, then stays put while its column is on screen. The example below shows the CSS.
Does a table of contents help SEO?
It helps readers find sections and gives each section a linkable address. Search engines sometimes show jump links to sections, but they decide when; there is no setting that guarantees it.
Related: Markdown to HTML, HTML to Markdown converter, Markdown cheat sheet, HTML formatter.
Start a 7-day free trial or see all free tools. On We.Inc you get a 7-day free trial, not a free plan: card needed, $0 today, cancel before it ends and you pay nothing. AI building is on paid plans from $20 a month.
More in Free Tools
- Tailwind Color Palette Generator
- Terms and Conditions Generator
- Text Diff Checker
- Text Gradient Generator
- Word to HTML Converter
- Time Card Calculator
- Token Counter
- Type Scale Generator
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App