GitHub Flavored Markdown (GFM)
GitHub Flavored Markdown, or GFM, is the Markdown that GitHub renders in READMEs, issues, pull requests and discussions. Strictly speaking, it's CommonMark with five extensions added on top. In everyday use, though, people also call GFM anything extra that GitHub renders: footnotes, alerts, math, @mentions. Most of those aren't in the GFM spec at all.
That gap causes real confusion. You write something that works on GitHub, paste it into another tool, and half of it breaks. This page sorts GFM into three layers, so you know what's standard, what's a GFM extension, and what only GitHub does.
New to Markdown itself? Start with the CommonMark Guide.
In simple terms: CommonMark provides a standardized foundation for Markdown. GFM builds on that foundation by adding features such as tables, task lists, strikethrough, extended automatic links, and footnotes. Outside GitHub, support for these extensions depends on the Markdown renderer being used.
GFM in Three Layers
- CommonMark base. Headings, paragraphs, emphasis, lists, links, images, blockquotes, inline code and fenced code blocks. Every CommonMark renderer handles these.
- The GFM spec extensions. Exactly five: tables, task list items, strikethrough, autolinks and disallowed raw HTML. They're marked "(extension)" in the spec.
- GitHub's own features. Footnotes, alerts, math, Mermaid diagrams, @mentions, issue and commit references, emoji shortcodes and more. GitHub documents and renders them, but the GFM spec doesn't define them.
The published spec is version 0.29, dated 6 April 2019. It calls GFM a strict superset of CommonMark: everything valid in CommonMark stays valid, and GFM only adds. So standard CommonMark always works on GitHub. The reverse isn't true. A CommonMark-only renderer won't understand layers 2 and 3.
The spec also says that github.com does extra post-processing and sanitising after the Markdown is converted to HTML, so what you see on GitHub isn't purely what the spec describes. And since the spec is older than some of what GitHub renders today, GitHub's own documentation is the better source for newer features such as alerts.
The Five Extensions in the Spec
| Extension | Spec section | What it adds |
|---|---|---|
| Tables | 4.10 | Rows and columns with pipes |
| Task list items | 5.3 | [ ] and [x] checkboxes in lists |
| Strikethrough | 6.5 | ~~text~~ |
| Autolinks | 6.9 | Bare URLs and emails become links |
| Disallowed raw HTML | 6.11 | A short list of HTML tags is neutralised |
1. Tables#
| Name | Role | Score |
|:-----|:----:|------:|
| Ana | Dev | 92 |
| Raj | QA | 88 |
Colons in the delimiter row set alignment: left, centre or right. Leading and trailing pipes are recommended, but the spec lets you leave them out.
Rules from the spec that catch people out:
- The header row and the delimiter row must have the same number of cells. If not, you don't get a table, just text with pipes.
- Later rows can be shorter or longer. Missing cells become empty, and extra cells are silently dropped.
- Cells hold inline content only. Block-level things like lists and headings can't go in a cell, and a row can't span lines (see Line Breaks for the
<br>workaround). - A literal pipe inside a cell is written
\|. - The table ends at the first blank line, or when another block starts, such as a blockquote line.
More on syntax and alignment: Markdown Tables.
2. Task list items#
- [x] Write the draft
- [ ] Review it
- [ ] Publish
The marker is a bracket pair holding a space (open) or an x (done), followed by at least one space before the text. Without the space inside [ ], it's just text. The spec turns the marker into a checkbox but doesn't say how it behaves when clicked. GitHub makes the boxes clickable in issues and pull requests. In a plain README they're display only. See Markdown Task Lists.
3. Strikethrough#
~~old price~~ new price
The spec defines strikethrough with two tildes on each side. GitHub's own docs also show a single tilde working on github.com, but the double form is the one the spec describes and other tools expect, so use that. Like other emphasis, it stops at a paragraph break.
4. Autolinks#
Bare web addresses become links with no brackets. The spec covers three forms:
- text starting with
www.followed by a valid domain (anhttpscheme is added for you) - URLs starting with
http://,https://orftp:// - email addresses (a
mailto:is added for you)
The link has to start at the beginning of a line, after whitespace, or after *, _, ~ or (. Trailing punctuation such as a full stop or comma is left out of the link, so "Visit www.example.com." links the address, not the dot. To choose your own link text, write a normal link instead. Syntax is on Markdown Links.
5. Disallowed raw HTML#
CommonMark lets raw HTML through. GFM neutralises nine tags by replacing the opening < with <, so they show up as text instead of running: title, textarea, style, xmp, iframe, noembed, noframes, script and plaintext. The match isn't case sensitive. Every other tag is left alone by the spec, though github.com's extra sanitising can still strip tags or attributes. If HTML is part of your page, see Markdown HTML.
What GitHub Adds on Top (Not in the Spec)
These work on github.com. Don't assume they work anywhere else.
| Feature | Syntax | Notes |
|---|---|---|
| Footnotes | [^1] and [^1]: text |
Documented by GitHub, not one of the spec's five. Not supported in wikis. See Footnotes |
| Alerts | > [!NOTE], also TIP, IMPORTANT, WARNING, CAUTION |
Elsewhere they usually show as an ordinary blockquote with the marker text visible |
| Math | $x^2$ inline, $$ blocks |
See Markdown Math |
| Mermaid diagrams | a fenced block tagged mermaid |
See Mermaid Diagrams |
| Colour swatches | `#0969DA`, or RGB or HSL, in backticks |
Issues, pull requests and discussions |
| @mentions | @username |
Links to a profile and notifies the person |
| Issue and PR references | #25, owner/repo#25 |
Resolve to links on GitHub only |
| Commit references | a commit SHA | Becomes a link to the commit |
| Emoji shortcodes | :rocket: |
See Markdown Emojis |
| Collapsed sections | <details> and <summary> |
Plain HTML that GitHub allows. See the HTML guide |
| Syntax highlighting | a language name after the opening fence | The fence is CommonMark, the colouring is GitHub. See Code Blocks |
| Heading anchors | automatic #section-name links |
Generated by GitHub for every heading |
How to use these in a README, issue or pull request is covered on GitHub Markdown. This page only tells you which layer each one belongs to.
Where GFM Works Outside GitHub
Support is per feature, not all or nothing.
| Tool | GFM support |
|---|---|
| remark | The remark-gfm plugin adds autolinks, footnotes, strikethrough, tables and task lists |
| Hugo (Goldmark) | Table, strikethrough, autolink (linkify) and task list extensions are on by default under markup.goldmark.extensions. Hugo's docs call Goldmark compatible with GFM |
| Pandoc | Reads and writes a gfm format |
| markdown-it | Follows CommonMark and adds optional syntax extensions and community plugins. Which GFM pieces you get depends on the preset and plugins |
| cmark-gfm | GitHub's fork of the cmark C library. The spec source lives in the same repository |
| GitLab | Has its own "GitLab Flavored Markdown", also shortened to GFM. Similar, not identical |
Notice that remark-gfm bundles footnotes with the five spec extensions, and Hugo turns its footnote extension on by default, even though footnotes aren't in the spec. That's one reason the two get mixed up.
How I'd Write for More Than One Renderer
If a file has to work outside GitHub, I'd stick to tables, strikethrough and task lists, and treat footnotes, alerts and math as GitHub-only until I've tested the target tool. If it only ever lives on GitHub, use whatever helps the reader.
Quick Test File
Paste this into a GitHub README, an issue or a gist, then into your other tool, and see which parts survive.
| Feature | Layer |
|---|---|
| Table | GFM spec |
- [x] Task item
- [ ] Open item
~~Strikethrough~~
www.example.com and https://example.com
Footnote test.[^1]
[^1]: A footnote.
> [!NOTE]
> An alert.
Whatever fails in the second tool tells you which layer it doesn't support. To try the syntax with live preview, open the Markdown Editor.
Common Mistakes
| Mistake | What happens | Fix |
|---|---|---|
| Header row and delimiter row have different cell counts | No table, just pipes | Match the counts |
| A data row has more cells than the header | Extra cells are dropped | Add a header column, or trim the row |
No space inside [ ] |
Not a task list item | - [ ] with a space |
A bare URL stuck to the previous character, like see:www.example.com |
No link, because autolinks must follow whitespace, a line start, or *, _, ~ or ( |
Add a space, or wrap the URL in <> |
Using <script> or <iframe> |
Shown as text or stripped | Link out instead |
Sources
Frequently Asked Questions
- 1
What does "strict superset of CommonMark" mean?
Anything that is valid CommonMark is valid GFM and renders the same way. GFM only adds syntax, it never changes the meaning of existing syntax.
- 2
Are footnotes part of GFM?
Not in the spec, which lists five extensions: tables, task list items, strikethrough, autolinks and disallowed raw HTML. GitHub supports footnotes and documents them, and some tools bundle them with their GFM option, which is why they're often treated as GFM.
- 3
Do alerts, math and Mermaid count as GFM?
In everyday use, yes. In the spec, no. They're GitHub features layered on top. Use them on GitHub and test elsewhere.
- 4
Will GFM work in GitLab or other tools?
Partly. GitLab has its own flavour with a similar name, and most Markdown libraries support some GFM features through built-in options or plugins. Test the specific feature in the tool you're using.
- 5
Is the GFM spec still updated?
The published spec is version 0.29 from April 2019. GitHub's documentation covers newer features such as alerts, so check it for anything beyond the five extensions.
- 6
Is @mention syntax GFM?
No. It's a GitHub platform feature, like issue and commit references.
- 7
Should I learn CommonMark or GFM first?
CommonMark. It's the base that GFM builds on. Add the extensions when you need tables, task lists or strikethrough.
