TOC Generator

Paste Markdown, get a linked, nested table of contents. GitHub-compatible anchors, adjustable depth — copy and drop at the top of your doc.

8 headings found
- [Getting Started](#getting-started)
  - [Installation](#installation)
    - [Requirements](#requirements)
    - [Downloading](#downloading)
  - [Configuration](#configuration)
- [Advanced Usage](#advanced-usage)
  - [Performance Tuning](#performance-tuning)
  - [Troubleshooting](#troubleshooting)

Slugs follow GitHub’s algorithm, so anchor links work inside READMEs, GitHub issues, and most static site generators. Headings inside fenced code blocks are ignored.

About this tool

The Markdown TOC Generator scans your document's H1–H6 headings and produces a nested table of contents with anchor links, ready to paste at the top of any long Markdown file. It uses GitHub-compatible slug rules (lowercase, spaces to hyphens, special characters stripped) so the links work the moment you commit.

You control which heading levels appear. For a typical blog post, H2 and H3 give a useful but not overwhelming outline; for reference docs, go up to H4 or H5. The tool ignores headings inside fenced code blocks so pseudo-headings in code samples don't pollute your TOC.

As with every mdkit tool, everything runs in your browser. Paste proprietary docs without worrying about upload — your content stays on your device.

How it works

  1. 1

    Paste your Markdown

    Paste the full Markdown document — or just the heading structure — into the input field.

  2. 2

    Set the heading depth

    Choose the minimum and maximum heading levels to include. Default is H2–H3, which works for most blog posts and READMEs.

  3. 3

    Copy the TOC

    The generated Markdown TOC appears on the right. Click copy and paste it at the top of your document, usually right after the title and summary.

Common use cases

  • Adding a navigation outline to the top of a long README
  • Generating an anchor-linked outline for docs site pages before committing
  • Building a TOC for a technical blog post that readers will skim
  • Producing a summary of a research document's structure for a collaborator
  • Quickly auditing the heading hierarchy of a doc — spotting skipped or duplicated headings

Frequently Asked Questions

Does this use GitHub-compatible anchor slugs?+
Yes. The slug algorithm matches GitHub's: lowercase the text, replace spaces with hyphens, strip punctuation, and append a numeric suffix for duplicate headings (-1, -2). Links work out of the box when you commit to GitHub.
Can I include all heading levels (H1–H6)?+
Yes. Set the maximum depth to 6. For most documents H2–H3 is enough; going deeper tends to produce a TOC that's noisier than the content itself.
Will it pick up headings inside code blocks?+
No. The generator skips any content inside fenced code blocks (```…```) or indented code blocks, so pseudo-headings in code examples won't pollute your TOC.
Does it handle duplicate heading text?+
Yes. If two headings have the same text, the second gets a -1 suffix in its anchor (like GitHub does), the third gets -2, and so on, so every link stays unique.
Can I regenerate the TOC when I update the document?+
Paste the updated Markdown, grab the new TOC, and replace the old block. Consider marking the TOC block with HTML comments (<!-- toc --> … <!-- /toc -->) so it's easy to find later.

Related tools

Learn more