MarkdownViewer

Markdown Table of Contents Generator

Generate a linked table of contents from your Markdown headings.

- [Getting Started](#getting-started)
  - [Installation](#installation)
    - [Requirements](#requirements)
  - [Usage](#usage)
    - [Basic example](#basic-example)
  - [FAQ](#faq)

What is the Markdown TOC Generator?

A Markdown TOC generator scans your document for headings and builds a nested table of contents with anchor links. Each link points to the auto-generated anchor of the matching heading, so readers can jump straight to a section. The nested indentation mirrors your heading hierarchy (h2 under h1, h3 under h2), which gives long documents and READMEs a scannable structure without manual linking.

Common Uses for the Markdown TOC Generator

  • Adding a table of contents to a long README or wiki page
  • Building navigation for a documentation file written in Markdown
  • Creating a contents section for a blog post or release notes
  • Linking sections in a GitHub issue or pull request description

Why long documents need a table of contents

Readers skim before they read. A linked TOC lets them confirm the document covers what they need and jump to it, which lowers bounce and increases time on page — both signals the tools below help you author. For documentation, a TOC is effectively a navigational map; leaving it out is the equivalent of shipping a book with no chapter list.

TOC vs Markdown heading structure

A good table of contents is only as good as the heading structure underneath it. If your document jumps from h1 straight to h4, or uses headings merely for bold text, the TOC will look broken — and so will the document for screen readers. Fix the hierarchy first (one h1, then h2 sections, then h3 subsections), then generate the TOC; it will come out clean and accessible.

Frequently Asked Questions

How are the anchor links generated?
Anchors follow the common GitHub-style rule: lowercase the heading text, remove punctuation, and replace spaces with hyphens. So 'Getting Started' becomes #getting-started. This matches how GitHub and many static site generators auto-link headings.
Does it handle nested headings?
Yes. The TOC is nested to mirror your heading levels — h3 sections are indented under their h2 parent, and h2 under h1. The depth is normalised to the shallowest heading in the document.
Will the links work on my platform?
They work wherever headings get auto-generated anchors, which includes GitHub, GitLab, most Markdown editor apps and common static site generators. A few custom themes change the anchor format; in that case adjust the slugs, but the structure will be right.
Does it read headings inside code blocks?
No. Headings inside fenced code blocks are ignored, so a code sample containing a line starting with # does not pollute the table of contents.

More Markdown Tools