Markdown TOC Generator (Auto from Headings)

Auto-generate a Table of Contents from Markdown headings. Select heading levels (like H2-H4), then copy editable output and paste it immediately.

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 in this page. You can also choose "Custom" or edit output manually.

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.
  • Output is editable so you can fine-tune for your renderer.
  • Input text is processed locally in your browser.

Related tools