1. Home
  2. Writing & text tools
  3. Markdown Table of Contents Generator

Markdown Table of Contents Generator

Give a long README, wiki page or set of notes a clickable contents list that matches the anchors GitHub and GitLab create, and update it whenever the headings change.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Markdown Table of Contents Generator

  1. Paste the Markdown.
  2. Choose the heading levels and list style.
  3. Copy the TOC, or the whole file with the TOC inserted.

Features

  • GitHub and GitLab anchor rules, including -1, -2 for repeated headings
  • ATX (#) and underlined headings; code blocks skipped
  • Bulleted or numbered, 2 or 4-space indents
  • Inserts between <!-- toc --> markers and replaces an old TOC
  • Table of every heading and its anchor

Supported formats

You can open

  • MD
  • Typed or pasted text

You get

  • MD
  • Copied text

Private by design

Your files are opened and processed by your browser on this device. They are never uploaded to openWorkstand or anyone else, so the Markdown Table of Contents Generator is safe for contracts, IDs, photos and work documents. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Very large files are limited by your device’s memory; on a phone, split huge files into smaller parts first.

Guide

Generating a table of contents for Markdown

A long README or documentation page is much easier to use with a table of contents at the top: readers see the structure and jump to the part they need. Writing one by hand is tedious, and the links break whenever a heading changes or the anchor rules are misunderstood. This generator reads your headings, builds the list with anchors that match GitHub or GitLab, and can insert it into the file for you.

How anchors are made

When GitHub renders Markdown, it gives every heading an anchor: the text in lower case, punctuation removed, each space turned into a hyphen. Underscores and hyphens are kept, and letters in other alphabets are kept too. A heading that appears twice gets -1 on the second occurrence, -2 on the third. GitLab follows nearly the same rules but merges runs of hyphens into one. Choose the platform and the links match.

Which headings count

Both heading styles are read: lines starting with # signs, and “setext” headings underlined with === or —. Anything inside a fenced code block is ignored, so an example heading in a code sample does not appear in the TOC. If a heading ends with an explicit id such as {#install}, that id is used as the anchor, as many site generators allow.

Levels and list style

By default the TOC covers levels 2 and 3 — the sections and subsections under the title. Widen or narrow the range as needed. Choose hyphen or asterisk bullets or a numbered list, and two- or four-space indentation; some linters and renderers insist on four spaces for nested lists, especially under numbered items. Turn links off for a plain outline.

Inserting and updating

“Whole file” returns your Markdown with the TOC placed between <!-- toc --> and <!-- tocstop --> comments. The first time, it goes straight after the H1 title. After you edit headings, paste the file in again: the list between the markers is replaced rather than duplicated. These are the same markers used by common TOC tools, so other tools can maintain the block too.

Checking anchors

The table under the output lists every heading with its level and anchor. Use it to check a link written by hand elsewhere in your documentation, or to spot duplicates that will get numbered suffixes.

A worked example

In the sample README, “Colours & themes” becomes #colours–themes, “What’s new in v2.0?” becomes #whats-new-in-v20, and the second “Getting started” becomes #getting-started-1. The heading inside the code block is left out.

Tips for a useful TOC

Keep headings short and distinct, since they become the TOC entries; avoid two sections with the same name at the same level; and limit the TOC to two levels on long pages so it stays a summary.

Linking to headings from elsewhere

The same anchors work in links from other pages: README.md#install on GitHub, or docs/setup.md#configuration in a documentation site. Before renaming a heading that other pages link to, search for its anchor; the old links break silently, landing at the top of the page instead of the section.

Convert the file to a web page with Markdown to HTML, write and preview it in the Markdown Editor, add collapsible FAQ sections with the HTML Accordion Generator, or make URL-safe names with the Slug Generator.

Checked against the current version of the Markdown Table of Contents Generator on .

Troubleshooting

The file does not open

Check that it is one of the supported formats above and opens in another app. Damaged files and password-protected PDFs cannot be read until they are repaired or unlocked.

It is slow or stops on a very large file

Everything runs on your device, so speed depends on its memory. Close other tabs, use a computer rather than a phone, or split the file into smaller parts first.

The download did not start

Look for your browser’s download bar or icon. Some browsers ask once before a site may download files; allow it and click the button again.

Frequently asked questions

Why are there two hyphens in some anchors?

Because GitHub removes punctuation but keeps the spaces around it. “Colours & themes” loses the ampersand and keeps both spaces, so it becomes colours--themes. GitLab merges repeated hyphens into one, which is why the two platforms differ.

Should the TOC include the H1 title?

Usually not. Most files have one H1, the title, and the TOC lists the sections under it, which is why the default range starts at level 2. Include level 1 only if your file uses several H1 headings as chapters.

Does the TOC update itself when I edit headings?

Not on its own; Markdown files are static. Paste the file back in after editing and copy the whole-file result: the old list between the markers is replaced with an up-to-date one.

Why does my link not jump to the heading?

Anchors must match exactly. GitHub lowercases the text, removes punctuation and turns each space into a hyphen, so “What’s new in v2.0?” becomes #whats-new-in-v20. This tool uses the same rules.

Does GitHub make its own table of contents?

GitHub shows an outline menu for README files, but it does not appear in the file itself, on other sites or in exported documents. A TOC in the Markdown works everywhere.

Keep working with the result

After you download, choose “Save to Workstand” to keep the result in a folder on your computer, attach it to a project and create a follow-up task. It is saved by your browser, not uploaded.