Free Markdown Table of Contents Generator (GitHub / GitLab / Pandoc Anchors)
Paste any Markdown document and get a clean linked table of contents using GitHub-, GitLab-, or Pandoc-style heading slugs. Configurable heading depth, indented nesting, ordered or unordered list, with duplicate-slug suffixes handled automatically.
- [Toolk Project Documentation](#toolk-project-documentation)
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [First Run](#first-run)
- [Architecture](#architecture)
- [Frontend Stack](#frontend-stack)
- [Component Library](#component-library)
- [Color Tokens](#color-tokens)
- [Typography](#typography)
- [Contributing](#contributing)
- [Code Style](#code-style)
- [Pull Requests](#pull-requests)
- [License](#license)Auto-Indented Nesting
Each heading depth (#, ##, ###) becomes one level deeper in the list output. Base level is normalized so the TOC starts flush regardless of the source's top heading.
Three Slug Styles
GitHub (default), GitLab, and Pandoc — pick the platform where the document will be rendered. Duplicate slugs auto-suffix with -1, -2, -3 (the GitHub convention).
Configurable Depth
Restrict to top-N levels (e.g. include only H1-H3 and skip the leaf-level sub-headings). Choose ordered (numbered) or unordered list output, 2 or 4 space indent.
100% Client-Side
Markdown documents may contain drafts, internal notes, or sensitive prose. The parser runs entirely in your browser — nothing leaves the page.
Anchors That Actually Work, On Every Platform
Every Markdown renderer auto-generates anchor IDs for headings, but the slugification rules vary by platform — GitHub keeps underscores, GitLab collapses them, Pandoc follows yet another convention. Hand-writing a TOC and guessing the slugs breaks half the links. Our Free Markdown TOC Generator applies the exact platform rule to each heading you have in the source, handles duplicate-slug suffixing automatically, and emits clean indented Markdown ready to paste at the top of your README or documentation page.
Pair this with our Markdown Editor (live writing tool), Markdown to HTML (one-shot conversion when you ship to non-Markdown systems), Markdown Table Generator (visual table-shaped Markdown builder), and the URL Slug Generator (sibling tool for non-heading URL slugs).
How Each Platform Slugifies Headings
| Platform | Slug Rule | Notes |
|---|---|---|
| GitHub | lowercase → replace whitespace with hyphens → drop everything except [a-z0-9-_] | Used by README anchors on github.com. Most permissive about underscores. |
| GitLab | lowercase → replace any non-alphanumeric run with single hyphen → trim hyphens | GitLab pages and wiki anchors. Stricter — collapses runs of punctuation. |
| Pandoc | Same as GitHub for common cases | Used by Pandoc-rendered HTML and many static-site generators. |
Where TOC Generation Helps
README and documentation
GitHub renders Markdown READMEs with auto-anchored headings — paste your draft and generate the TOC to put at the top.
Blog posts
Long-form posts benefit from a TOC for scannability. Generate one quickly from your draft headings.
Technical specifications
RFC-style specs and design docs need a TOC. Generating it deterministically prevents drift between body and TOC.
Wiki pages
GitLab and Confluence wikis use slug-based anchors. Pick the right slug style for your platform.
Documentation sites
Static-site generators (Docusaurus, MkDocs, VitePress) can auto-generate TOCs at build time, but a generator helps when porting drafts.
Four TOC Authoring Tips
1. Stop at H3 for Most Documents
H4 and deeper rarely belong in a top-level TOC. The signal-to-noise tips against you. Set Max Level to H3 for blogs, H4 for long technical specs.
2. Keep Headings Concise
Long headings produce long slugs and ugly anchor URLs. Aim for 2-6 words per heading. Move detail to the heading's body text.
3. Avoid Duplicate Heading Text
Duplicates auto-suffix with -1, -2, etc. which produces fragile anchors (the link target shifts when you insert/remove sections). Make heading text unique.
4. Regenerate After Big Edits
If you reshuffle sections, the TOC at the top drifts. Re-paste the document here and re-extract — takes 5 seconds and prevents broken anchors.