Markdown TOC Generator (Auto from Headings)

Generate a table of contents from Markdown headings. Choose the heading levels, then copy the result into your document and edit it there.

Supports H2-only, anchor modes, and duplicate headings without extra setup.

Your text stays local in the browser and is never uploaded.

How to use (30 sec)

  1. Paste your Markdown text.
  2. Choose heading levels (H2-only / H2-H4, etc.).
  3. Copy the generated TOC and paste it into your document.

Input and output example

Example with duplicate headings

Input

# Document Title
## Overview
## Usage
### Install
### Settings
## FAQ
## FAQ

Output (H2-H3 / bullet list / TOC heading ON)

## Table of contents

- [Overview](#overview)
- [Usage](#usage)
  - [Install](#install)
  - [Settings](#settings)
- [FAQ](#faq)
- [FAQ](#faq-2)

Specification (anchor and duplicate rules)

Heading extraction rules

  • Extracts ATX headings (# to ####) in the selected range.
  • Ignores lines inside fenced code blocks (``` ... ```).
  • Use level filter (H2 only / H2-H3 / H2-H4 / H1-H4).
  • Setext headings (=== / ---) are not included in the first version.

Anchor generation rules (tool rule)

  1. Trim heading text.
  2. Lowercase alphabetic letters.
  3. Convert spaces to '-'.
  4. Remove symbols except '-'.
  5. Collapse repeated '--' into '-'.
  6. Trim leading and trailing '-'.
  7. Append -2, -3 ... when duplicate anchors occur.

TOC link behavior may differ by hosting platform and Markdown viewer. Edit output as needed.

FAQ

Can I generate H2-only TOC?

Yes. Choose "H2 only" in Heading levels.

How is anchor text decided?

Anchors follow the rule described on this page. You can also choose "Custom" or adjust links after pasting them into your document.

How are duplicate headings handled?

Duplicate headings get suffixes such as -2, -3 to keep anchors unique.

Can I exclude specific headings from TOC?

Yes. Use Exclude keywords in Advanced settings.

Can I generate TOC without links?

Yes. Select anchor mode "No anchors".

Notes

  • Anchor behavior varies by Markdown environment.
  • After copying, edit the TOC in your document to suit your Markdown renderer.
  • Input text is processed locally in your browser.