Markdown TOC Generator
Generate a Markdown table of contents from your headings, with linked anchor slugs in GitHub, GitLab, or Pandoc style. Set the depth range, choose a numbered or bulleted list, and copy the result. Free and 100% in your browser.
- [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.
Markdown TOC Generator: build a linked table of contents from your headings
A Markdown TOC generator reads the #, ##, and ### headings in your document and outputs a nested, linked table of contents you paste at the top. Each entry uses the anchor slug that GitHub, GitLab, or Pandoc generates — lowercased, hyphenated, punctuation stripped — so the links jump to the right section. Pick a depth range and list style, then copy. It is free, and runs 100% in your browser.
How to generate a Markdown table of contents
- Paste your Markdown into the input pane, or press Sample to load an example document.
- Set Min level and Max level to choose which heading depths appear (default H1 to H4).
- Choose a Slug style — GitHub, GitLab, or Pandoc — to match where the document will render.
- Pick Indent (2 or 4 spaces), toggle Numbered list for ordered output, and toggle Include #anchors off for a plain-text list.
- Press Copy on the Table of contents pane and paste the result at the top of your README or post.
What is an anchor slug, and how is it generated?
When a Markdown renderer turns a heading into HTML, it adds an id attribute so the heading can be linked directly with a #fragment URL. That id is the slug. The WHATWG HTML standard defines how a browser scrolls to that fragment, but the slug text itself is decided by the renderer. GitHub's rule is the most widely copied: lowercase the heading, drop punctuation, and replace each run of spaces with a single hyphen. The reference implementation is github-slugger, which the GitHub team mirrors for README anchors.
This tool also nests by heading level: an ## under an # indents one step, an ### two steps, and so on. It detects the smallest level used and treats it as depth zero, so a document that starts at H2 still produces a flush-left TOC. Duplicate slugs are disambiguated with -1, -2, -3 suffixes, exactly as GitHub does.
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. |
Worked examples: heading → slug → TOC line
Plain heading · GitHub style
## Getting Started → - [Getting Started](#getting-started)
Punctuation · GitHub style
### What is New in 2026? → [What is New in 2026?](#what-is-new-in-2026)
Underscores · GitHub vs GitLab
## node_modules → #node_modules (GitHub) vs #node-modules (GitLab)
Edge case · emoji & non-Latin headings
A heading like ## 你好 World reduces to #world in this tool, because it strips non-ASCII characters. On github.com the same heading anchors as #你好-world, since GitHub keeps Unicode letters. For non-Latin or emoji headings, confirm the rendered anchor on the target platform before relying on the link.
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.
The slug detail that silently breaks anchors
Most TOC generators advertise "GitHub-compatible" slugs but quietly drop characters GitHub keeps. This tool's GitHub rule allows only a-z, 0-9, hyphen, and underscore, then strips everything else. Real GitHub, per github-slugger, preserves Unicode letters — so привет stays привет on github.com but collapses here. For purely ASCII headings the two match exactly; the divergence only appears with accented, Cyrillic, CJK, or emoji text.
The practical fix is the same advice that prevents most broken anchors: keep heading text ASCII and unique. Duplicate headings auto-suffix with -1, -2, which makes a link target shift the moment you insert or remove a section above it. Unique, plain headings produce stable slugs that survive reorders.
Four TOC authoring tips
1. Stop at H3 for most documents
H4 and deeper rarely belong in a top-level TOC. 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 to 6 words and move detail to the body text.
3. Avoid duplicate heading text
Duplicates auto-suffix with -1, -2, which produces fragile anchors that shift when you insert or remove sections.
4. Regenerate after big edits
If you reshuffle sections, the TOC at the top drifts. Re-paste the document and re-extract — it takes seconds.
Runs 100% in your browser
Your Markdown never leaves your device. The parser walks the input in JavaScript inside the page and builds the TOC in memory — no uploads, nothing leaves your device. I tested it on README drafts, a 200-heading spec, documents that start at H2, files with fenced ``` code blocks containing # comments, and duplicate-heading edge cases across all three slug styles. Headings inside code fences are correctly skipped, and the output stays instant even on large documents.
Frequently asked questions
Is this Markdown TOC generator free?
Yes — 100% free with no signup and no usage cap. All three slug styles and every depth option are available.
Are my Markdown documents sent to a server?
No. The parser runs entirely in your browser and the TOC is built in memory. There is no fetch, no upload, and no analytics event carrying your content.
Does it skip headings inside code blocks?
Yes. Fenced code blocks marked with ``` or ~~~ are ignored, so a line like # define in a Bash sample is not mistaken for an H1.
Can I output a TOC without anchor links?
Yes. Turn off Include #anchors to get a clean indented list of heading text only — useful for changelogs, code-review notes, and AGENTS.md files.
Related Markdown, content & web utilities
Write and preview Markdown live
Markdown to HTMLConvert Markdown to clean HTML
Markdown Table GeneratorBuild table-shaped Markdown visually
URL Slug GeneratorMake clean slugs for page URLs
Word CounterCount words and reading time in a draft
Token CounterEstimate LLM tokens for Markdown docs
HTML FormatterTidy the HTML your Markdown renders to
HTML Entity ConverterEscape special characters for HTML
Meta Tag PreviewerPreview title and description snippets
Open Graph GeneratorGenerate OG tags for shared links
Guide: Markdown SyntaxHeadings, links, and formatting reference
Guide: Text Tools for CreatorsThe text-processing workflow guide
All ToolsBrowse the full Toolk hub
Last updated: June 2, 2026 · Runs 100% in your browser — no uploads, nothing leaves your device.
Need a different tool?
Browse all 89 free, in-browser tools — or tell us what we should build next.