Skip to content

Markdown Slug Generator

Preview GitHub heading anchors before you publish

Ship README deep links and documentation TOCs with confidence: inspect slug collisions early, copy nested Markdown lists, and stay aligned with GitHub's heading permalink algorithm — entirely client-side.

Input6 headings
GitHub-style anchors

Slugs match GitHub's heading algorithm (including -2 suffixes for duplicates).

LineLvHeadingSlug
11Introductionintroduction
52API Referenceapi-reference
73Authenticationauthentication
93Errorserrors
112FAQfaq
133Billingbilling
TOC preview (Markdown list)
- [Introduction](#introduction)
  - [API Reference](#api-reference)
    - [Authentication](#authentication)
    - [Errors](#errors)
  - [FAQ](#faq)
    - [Billing](#billing)

Who needs predictable anchors?

  • Docs engineers wiring intra-page jumps inside README files or MkDocs sites.
  • Training teams publishing reproducible deep links in LMS platforms that slug headings independently.
  • OSS maintainers coordinating changelog anchors across forks without preview deployments.

Knowing slugs before merge avoids broken fragment URLs inside automation scripts or Slack bookmarks.

How to use this generator

  1. Paste Markdown containing ATX headings — starter sample illustrates duplicates.
  2. Review the GitHub-style anchors table for line numbers, depth, text, and slug.
  3. Tap any row's copy icon for a single slug (paste after # in URLs).
  4. Click Copy TOC as Markdown to grab nested bullets ready for README intros.
  5. Paste into GitHub, GitLab, or static generators — cross-check once if non-Latin scripts dominate titles.

The slug algorithm mirrors Markdown Viewer's internal outline helper, so what you see here matches our editor sidebar and generated blog TOCs.

Slug rules at a glance

Input nuanceSlug behavior
Mixed caseLowercased entirely
Special charactersStripped; spaces become hyphens
Multiple adjacent hyphensCollapsed to one
Duplicate titlesSecond occurrence gains -2, third -3, …
Closing hashes on headingsTrimmed before slugging

Other hosts (GitLab, Bitbucket, MDX plugins) sometimes diverge slightly — diff-check important anchors there.

Nested TOC formatting

Indentation mirrors heading depth relative to the shallowest level detected so nested sections remain visually grouped — identical strategy to choosing Generate table of contents inside the editor tools sidebar.

After anchors look good, polish prose with the Markdown formatter or ship exports via Markdown to HTML.

Frequently asked questions

Do duplicate headings get unique IDs?
Yes — identical titles receive `-2`, `-3`, … suffixes in scan order, mirroring GitHub's renderer so relative anchor links stay stable.
How are slugs derived?
Lowercase, punctuation stripped to dashes, whitespace collapsed, trailing hashes trimmed — the same recipe GitHub documents for heading permalinks.
Does this handle emoji or symbols inside headings?
Emoji remain Unicode characters that slugify down using our normalization rules; compare against GitHub preview when emoji-heavy titles must match exactly.
Does this handle Setext-style headings?
Only ATX headings (`#` syntax). Underlined headings aren't detected — normalize them in the [editor](/editor) before generating anchors.
Can I paste the TOC into GitHub?
Absolutely. The nested bullets ship `[text](#slug)` links GitHub understands without extra configuration.
Will headings inside code fences appear?
No. Fenced blocks are ignored so tutorial snippets don't pollute your TOC.