Markdown Table of Contents Generator
Markdown Table of Contents Generator turns matched # headings into indented Markdown links. Anchor slugs are lowercased, Unicode-normalized, diacritics removed, non-letter/number runs replaced with hyphens, and edge hyphens trimmed. Renderers use different anchor algorithms, especially for punctuation, emoji, Unicode, and duplicate headings, so generated links require testing.
Runs locally — files stay on your deviceWill these TOC anchors work in every Markdown renderer?
No. Heading-id generation is renderer-specific, and this tool does not disambiguate duplicate headings.
A TOC link depends on the renderer's generated heading id
Markdown itself does not define a universal anchor-slug algorithm. Platforms choose how to normalize heading text and handle duplicate ids.
How it works
ATX headings are matched line by line. Each becomes an indented list item, and its text is passed through the tool's locale-lowercase and normalization slug function.
Key concepts
Duplicate headings collide
This implementation emits the same anchor twice rather than adding a suffix.
Heading jumps still indent
A jump from h1 to h4 produces three indentation levels even if the outline is structurally odd.
When to use it
- Draft a TOC for a controlled document.
- Preview this tool's slug policy.
- Create nested bullets from heading levels.
When not to use it
- Do not assume compatibility with GitHub, GitLab, Obsidian, or every static-site generator.
- Do not expect code-fence awareness.
- Do not rely on duplicate heading links.
Worked examples
Simple outline
- Input
# Guide\n## Setup- Expected output
- [Guide](#guide) with nested Setup
Level controls two-space indentation.
Diacritic
- Input
## Întrebări- Expected output
Anchor normalized without the combining mark
NFKD normalization removes marks.
Duplicate
- Input
## Setup\n## Setup- Expected output
Two links to #setup
No duplicate suffix is generated.
Common mistakes
Skipping renderer testing
Anchor policies differ. Correction: Render and click every generated link.
Using duplicate headings
Both links target the same slug here. Correction: Rename headings or adjust anchors manually.
Expecting Setext or fence awareness
Only regex-matched ATX lines participate. Correction: Use a parser integrated with the target renderer.
Best practices
- Generate TOCs with the same renderer used for publishing.
- Avoid duplicate headings.
- Keep heading hierarchy coherent.
Related operations and differences
Markdown Heading Extractor
Choose Markdown Heading Extractor when you need to list heading levels and text from Markdown.; use Markdown Table of Contents Generator specifically for toc.
CSV to Markdown Table
Choose CSV to Markdown Table when you need to turn comma-separated rows into a Markdown table.; use Markdown Table of Contents Generator specifically for toc.
Document Link Extractor
Choose Document Link Extractor when you need to extract labeled links from Markdown or HTML.; use Markdown Table of Contents Generator specifically for toc.
HTML to Markdown Converter
Choose HTML to Markdown Converter when you need to convert common HTML elements into clean Markdown.; use Markdown Table of Contents Generator specifically for toc.
Markdown Table Generator
Choose Markdown Table Generator when you need to generate an empty Markdown table with custom columns.; use Markdown Table of Contents Generator specifically for toc.
Markdown Table to CSV
Choose Markdown Table to CSV when you need to convert a Markdown table into CSV rows.; use Markdown Table of Contents Generator specifically for toc.
Limitations and privacy
- ATX regex only.
- Renderer-specific slugs may differ.
- No duplicate resolution, Setext, code-fence, custom-id, or link verification.
Document text is transformed locally in this browser.
Frequently asked questions
Are duplicate anchors disambiguated?
No.
Are Setext headings included?
No.
Are accents normalized?
Combining marks are removed after NFKD normalization.
Will links work everywhere?
Not necessarily.