Markdown TOC Generator
Paste your Markdown and instantly get a linked Table of Contents with GitHub-compatible anchor slugs — ready to copy and paste.
Your TOC will appear here
Start typing or paste Markdown on the left
How It Works
Paste any Markdown document — the tool scans every line for headings (# to ######).
Each heading gets a GitHub-compatible anchor slug: lowercase, spaces become hyphens, punctuation stripped. Duplicates get -1, -2 suffixes.
The result is a nested bullet list of - [Heading](#anchor) links. Copy and paste it at the top of your document.
💡 Tips
- • GitHub, GitLab, and most Markdown renderers all support these anchor links natively.
- • Set Max depth: H2 for a clean top-level TOC — skip H1 if your doc only has one title.
- • The tool strips inline formatting (
**bold**,`code`,_italic_) from heading text before generating slugs. - • Duplicate headings are handled automatically with
-1,-2suffixes, matching GitHub behaviour.
About Markdown TOC Generator
The Markdown TOC Generator automatically builds a linked Table of Contents from the headings in your Markdown document. Paste any Markdown file and get a ready-to-use, GitHub-compatible TOC in seconds — no manual writing or copy-pasting heading names one by one.
- Generates GitHub-compatible anchor slugs (lowercase, hyphenated, punctuation stripped)
- Handles duplicate headings automatically with
-1,-2suffixes - Configurable max depth — from H1 only up to H6
- Configurable indentation — 2 spaces, 4 spaces, or tab
- Strips inline Markdown formatting (bold, italic, code) from heading text before generating slugs
- Works entirely in your browser — no data is sent anywhere
How to Use the Markdown TOC Generator
- 1
Paste your Markdown
Paste your full Markdown document into the left panel. Any content is fine — the tool only scans lines that start with
#to######. - 2
Set your depth and indent
Choose the maximum heading level to include (e.g. H3 = H1, H2, H3 only) and your preferred indentation style. H2 is the most common choice for clean top-level TOCs.
- 3
Review the generated TOC
The right panel updates instantly as you type. Check the heading count and make sure all sections are captured.
- 4
Copy and paste into your document
Click Copy TOC and paste it at the top of your Markdown file, just below your title. GitHub, GitLab, and most Markdown renderers will render it as clickable links.
Tip: Use Max depth: H2 if your document only has one H1 title — this keeps the TOC clean with just the top-level sections listed.
Common Use Cases
GitHub README Files
- • Add a TOC to long README.md files
- • Help contributors navigate installation, usage, and API sections
- • Anchor links work natively on GitHub without plugins
Technical Documentation
- • Generate TOCs for API docs, wikis, and guides
- • Works with GitLab, Notion exports, and Confluence Markdown
- • Reduces time spent manually maintaining nav links
Blog Posts & Articles
- • Add a clickable contents section at the top of long articles
- • Useful for static site generators like Jekyll, Hugo, and Astro
- • Improves reader navigation and time-on-page
Developer Notes & Wikis
- • Add TOCs to personal knowledge base notes (Obsidian, Logseq)
- • Organise runbooks and playbooks with jump links
- • Keep team wikis navigable as they grow
Frequently Asked Questions
What is a Markdown Table of Contents?
A Markdown Table of Contents is a list of linked headings at the top of a document. Each item links to a heading anchor lower in the document, letting readers jump directly to sections they care about.
Are the anchor slugs compatible with GitHub?
Yes. This tool uses GitHub's slug algorithm: text is lowercased, spaces become hyphens, and most punctuation is removed. Duplicate headings get -1, -2 suffixes, exactly matching GitHub's behaviour.
Does it work with GitLab and other Markdown renderers?
GitHub-style slugs work on GitHub, GitLab, Bitbucket, and most static site generators (Jekyll, Hugo, Astro, Docusaurus). Some renderers use slightly different slug rules — test by clicking a link after pasting into your target platform.
What does "Max depth" do?
Max depth controls which heading levels are included. Setting it to H2 means only H1 and H2 headings appear in the TOC. Setting it to H3 includes H1, H2, and H3. Deeper headings are ignored, keeping the TOC concise.
How are duplicate headings handled?
If two or more headings have the same text (e.g. multiple "Overview" sections), the first gets the normal slug and subsequent ones get -1, -2 appended. This matches how GitHub resolves duplicate anchors.
Does inline formatting affect the TOC links?
No. The tool strips inline Markdown formatting — bold, italic, and code — from heading text before generating anchor slugs, so links resolve correctly regardless of how headings are styled.
Is my data safe? Does this tool send data to a server?
No data leaves your browser. All TOC generation happens entirely client-side using JavaScript. Your Markdown content is never uploaded, stored, or shared anywhere.