Markdown Heading Anchor Generator (GFM slug)
GitHub auto-generates anchor links for every heading in a Markdown file, with specific slug rules — lowercase, spaces to dashes, certain characters stripped, duplicate handling. This tool generates the exact anchor ID GitHub would use, so your in-page links don't break.
How to use the Markdown Heading Anchor Generator (GFM slug)
Paste your headings, one per line, keeping the leading # markers. The tool outputs the anchor ID GitHub generates for each — the fragment you put after # in a same-page link. Duplicate headings get a numeric suffix, exactly as GitHub does it.
How GitHub turns a heading into an anchor
When GitHub renders a Markdown file, it gives every heading an id so you can link straight to it with #the-heading. The slug is produced by a fixed recipe: lower-case the text, drop anything that is not a letter, number, space, or hyphen, then replace each run of spaces with a single hyphen. So “Installation & Setup” becomes installation--setup — the ampersand vanishes and the two surrounding spaces both become hyphens.
Repeated headings are disambiguated by appending -1, -2, and so on to the second and later occurrences. Getting these rules exactly right matters because a table of contents or cross-reference with the wrong slug silently links nowhere. This tool applies GitHub's GFM algorithm so the anchors you write match the ones GitHub actually emits.
Common use cases
- Hand-written tables of contents — produce anchor links that land on the right heading.
- Cross-references — link from one part of a README to another by its exact slug.
- Fixing broken in-page links — find why a
#anchorjumps nowhere by checking the real slug. - Duplicate headings — see the
-1,-2suffixes GitHub adds when titles repeat. - Docs tooling — pre-compute anchors when generating documentation that links into GitHub.
Frequently asked questions
How does GitHub build a heading anchor?
How are duplicate headings handled?
-1, -2, and so on appended in order. This tool tracks duplicates across all the headings you paste so the suffixes match GitHub.