Markdown TOC Generator

Anchors

How it Works

The Markdown TOC Generator analyses your source Markdown code to extract Heading tags (e.g. #, ##) and build a navigation tree.

1. Parsing Headings

The tool uses a tokenizer to scan the text, ignoring # symbols inside code blocks to accurately identify the document structure.

2. Generating Anchors (Slugs)

It generates anchor links following the GitHub Flavored Markdown (GFM) standard. For example, "Hello World!" becomes #hello-world.

3. Building the Tree

Based on the heading levels (H1-H6), it automatically creates an indented list, forming a clean Table of Contents.

Use Cases

GitHub README

Generate a professional navigation table for your open-source project's README.md, helping users find content quickly.

Tech Blogging

Insert generated TOC directly into Hugo, Hexo, or Jekyll blog posts to improve readability for long articles.

API Documentation

Organize complex API documentation by generating a clear index of endpoints and sections.

Freqently Asked Questions

Does it support GitHub style anchors?
Yes. The tool defaults to using the GFM (GitHub Flavored Markdown) algorithm: lowercase, remove non-alphanumeric chars, and replace spaces with hyphens.
How does it handle '#' in code blocks?
This tool uses a professional Markdown parser (Marked.js) which intelligently recognizes and ignores # symbols inside code blocks.
Can I generate numbered lists?
Yes. Select "1. (Ordered)" in the "List Style" settings above, and the TOC will use numbered list formatting (1. 1.1 1.2 ...).
Are non-English headings supported?
Yes. Unicode characters (including Chinese, Japanese, etc.) are preserved in anchor links, which is compatible with most modern Markdown engines like VS Code and GitHub.
Can I insert this directly into my MD file?
Absolutely. Just copy the generated TOC block and paste it anywhere in your Markdown file (usually at the very top).
Do all Markdown editors support this?
Not all editors support the magic [TOC] syntax, but the output from this tool is standard Markdown list syntax, which is compatible with 100% of Markdown viewers.
How are duplicate headings handled?
The current algorithm does not auto-suffix duplicates (like -1, -2) for simplicity. If you have duplicate headings, we recommend renaming them slightly to ensure unique linking.
Is my data sent to a server?
Never. All Markdown parsing and generation happens locally in your browser (Client-side).

More Free Tools