Markdown Table of Contents Generator

Paste a README or open Markdown files, choose the heading levels and anchor style, and insert a linked TOC that you can refresh later between two comment markers.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Add your Markdown

    Paste it into Document or drop one or more files.

  2. 2
    Choose the anchor style

    Pick GitHub, GitLab, Bitbucket or a custom ASCII slug.

  3. 3
    Set the depth

    Choose From level and To level and whether to skip the title.

  4. 4
    Style the list

    Pick bullets or numbers, indent and headings to leave out.

  5. 5
    Insert

    Press Insert into document, or Update TOC when markers exist.

  6. 6
    Save

    Copy the TOC, download the document, or download a ZIP for several files.

About this tool

A long README or guide is much easier to use with a table of contents at the top, but writing one by hand means working out the anchor of every heading and keeping the list in sync as sections move. The anchors are the hard part: GitHub lowercases the heading, drops punctuation, turns each space into a hyphen without merging them, and appends -1, -2 to repeated headings, so Install & Run becomes install--run. GitLab collapses repeated hyphens, Bitbucket adds a markdown-header- prefix, and many static site generators use plain ASCII slugs without accents. This generator reads the headings of your document, written with hash marks or with = and - underlines, ignores anything inside fenced code, and writes a nested list of links for the levels you choose. An outline view shows each heading with its level, anchor and line number, so you can see at a glance where the structure jumps from H2 straight to H4.

Options

From level and To level limit the depth; most READMEs list H2 and H3 only and skip the document title. List style chooses dash, star or plus bullets or a numbered list with numbers per level. Indent sets two or four spaces per level, which matters for some renderers. Link each entry can be switched off for a plain outline. Leave out removes headings such as Changelog or License by name.

Insert and update in place

Insert into document puts the TOC after the first H1 and wraps it in two HTML comments, toc and tocstop. Comments are invisible on GitHub and in most renderers. The next time you press the button after editing headings, only the text between the markers is replaced, so the rest of the file is untouched. The same markers are used by popular editor extensions and command-line tools, so a TOC made here can be refreshed by them too and the other way round.

Many files at once

Drop several Markdown files and each one gets its own TOC with the current options, inserted or updated between markers, and the set downloads as a ZIP. This is handy for a docs folder where every page should start with a short contents list.

Limits

Headings written as HTML h2 tags, headings created by MDX components and headings inside block quotes or lists are not included. Anchors follow the published rules of each platform, but renderers that add their own suffixes or remove emoji differently may not match in rare cases; the Markdown link checker on this site can confirm every anchor. The tool does not renumber the headings themselves.

Worked example

A 230-line README has one H1, 7 H2 and 12 H3 headings, including two H2 sections both called Examples. With levels H2 to H3, GitHub anchors and Changelog left out, the TOC lists 18 entries: the second Examples links to #examples-1 and Install & Run links to #install--run. Insert into document places it under the title between the markers. Two weeks later a new H3 called Docker is added, and pressing Update TOC in document replaces only the 20 lines between the markers.

Quick facts

Frequently asked questions

Which anchor style does GitHub use?

Lowercase text, punctuation removed except hyphens and underscores, every space turned into a hyphen and -1, -2 added to repeats. Choose GitHub; it is also right for VS Code preview and Gitea.

Why does my TOC start at H2?

Most documents have one H1 title and the contents list starts at the sections below it. Set From level to H1 and untick Skip the document title to include it.

What are the toc and tocstop comments for?

They mark where the generated list starts and ends. Re-running the generator replaces only that part, so you never get two tables of contents in one file.

Can I make a numbered contents list?

Yes. Choose 1. numbered under List style. Each level starts its own numbering and nested items are indented far enough for renderers to nest them.

What happens when headings skip a level?

The TOC nests the deeper heading one level below its parent so the list stays valid, and the outline shows a warning so you can fix the heading levels.

Is my document uploaded?

No. Everything runs in this tab, and the document and options are kept only in local storage on this device.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages