GitHub Flavored Markdown (GFM) cheat sheet
Updated
GitHub Flavored Markdown is CommonMark plus five spec extensions — tables, task lists, strikethrough, bare-URL autolinks and an HTML tag filter — and github.com layers alerts, footnotes, math, mermaid, emoji shortcodes, @mentions and issue references on top. Each block below shows the syntax on the left and the rendered result on the right; the tables say which features are in the spec and which only work on github.com.
GFM vs CommonMark vs github.com
"GFM spec" is what any GFM-compatible renderer (remark-gfm, GitLab, cmark-gfm) must support. "github.com" is what the website renders on top of the spec.
| Feature | Syntax | CommonMark | GFM spec | github.com |
|---|---|---|---|---|
| Tables | | a | b |
| --- | --- | | — | Yes (extension) | Yes |
| Task lists | - [ ] todo / - [x] done | — | Yes (extension) | Yes, clickable in issues |
| Strikethrough | ~~text~~ or ~text~ | — | Yes (1 or 2 tildes) | Yes |
| Autolinks (bare URLs) | https://… or www.… | Only <https://…> | Yes (extension) | Yes |
| Disallowed raw HTML | <script>, <style>, <iframe>… | Passed through | Filtered (tagfilter) | Filtered |
| Footnotes | text[^1] … [^1]: note | — | Not in spec | Yes (not in wikis) |
| Alerts | > [!NOTE] | — | Not in spec | Yes, 5 types |
| Math | $x^2$, $$…$$, ```math | — | Not in spec | Yes (MathJax) |
| Mermaid diagrams | ```mermaid | — | Not in spec | Yes (+ geojson, topojson, stl) |
| Emoji shortcodes | :tada: | — | Not in spec | Yes |
| @mentions | @user, @org/team | — | Not in spec | Yes (notifies) |
| Issue / PR references | #26, GH-26, owner/repo#26 | — | Not in spec | Yes (not in wikis or files) |
| Commit SHA links | a5c3785…, owner/repo@sha | — | Not in spec | Yes |
| Collapsible sections | <details><summary> | Raw HTML | Raw HTML | Yes, styled |
| Color chips | `#0969DA` | Inline code | Inline code | Issues, PRs, discussions only |
| Heading anchors | [Jump](#my-heading) | No ids generated | No ids generated | Auto-generated slugs |
| Underline | <ins>text</ins> | Raw HTML | Raw HTML | Yes |
| Sub / superscript | <sub>2</sub> <sup>2</sup> | Raw HTML | Raw HTML | Yes |
Text styling
Bold, italic, strikethrough
**bold** or __bold__
*italic* or _italic_
***bold italic***
~~strikethrough~~ or ~strikethrough~bold or bold
italic or italic
bold italic
strikethrough or strikethrough
GFM accepts one or two tildes for strikethrough; three or more do nothing. Most other renderers need exactly two.
Subscript, superscript, underline (HTML)
H<sub>2</sub>O and E = mc<sup>2</sup> and <ins>underlined</ins>No markdown syntax for these on GitHub — the docs prescribe the <sub>, <sup> and <ins> tags. This preview strips raw HTML; GitHub renders it.
Color chip (issues, PRs, discussions only)
Brand blue is `#0969DA`, also `rgb(9, 105, 218)` or `hsl(212, 92%, 45%)`.Brand blue is #0969DA, also rgb(9, 105, 218) or hsl(212, 92%, 45%).
A HEX, RGB or HSL value in backticks with no spaces inside gets a colour swatch — but only in issues, pull requests and discussions, never in .md files.
Tables
Table with alignment
| Left | Center | Right |
| :--- | :----: | ----: |
| a | b | c || Left | Center | Right |
|---|---|---|
| a | b | c |
Needs a header row and a delimiter row of at least three dashes per column; colons set alignment. A literal | inside a cell must be written \|.
Task lists
Checkboxes
- [x] Write the code
- [ ] Write the tests
- [ ] \(Optional) Open a follow-up issue- Write the code
- Write the tests
- (Optional) Open a follow-up issue
In issues and PRs the boxes are clickable and the file updates. Escape a leading parenthesis after the box (\() or the item breaks.
Links, autolinks and references
Bare URLs and www. autolinks
Docs at https://docs-md.com or www.example.com, mail hello@example.comDocs at https://docs-md.com or www.example.com, mail hello@example.com
The GFM autolink extension recognises http://, https://, www. and e-mail addresses without angle brackets. CommonMark needs <https://…>.
Section link to a heading
## Step 2: Install
See [the install step](#step-2-install).Step 2: Install
See the install step.
GitHub slugs: lowercase, spaces to hyphens, other punctuation removed, markup stripped, duplicates get -1, -2. Edit the heading and the anchor changes.
Relative link to a file in the repo
[Contributing](docs/CONTRIBUTING.md) and [root file](/README.md)Paths are relative to the current file; a leading / means the repository root. Keep link text on one line — a link broken across lines does not work.
Issue, PR and commit references (github.com only)
Fixes #26, see GH-26 and jlord/sheetsee.js#26.
Commit a5c3785ed8d6a35868bc169f07e40e889087fd2e or jlord/sheetsee.js@a5c3785Converted to short links in issues, PRs, discussions and commit messages — not in wikis or in files rendered from the repository.
@mentions
cc @octocat and @github/docs-teamMentioning notifies the person or every team member — only if they have read access to the repository.
Code
Fenced block with language
```diff
- const old = 1;
+ const fresh = 2;
```- const old = 1;
+ const fresh = 2;
The identifier after the fence picks the highlighter (Linguist). Unknown tags fall back to plain text — see the language table below.
Inline code and the `#` color chip trap
Run `git status`; a value like `#0969DA` gets a colour swatch in issues.Run git status; a value like #0969DA gets a colour swatch in issues.
Alerts
A blockquote whose first line is [!TYPE] renders as a coloured callout with an icon on github.com. Five types, uppercase, one per blockquote; they cannot be nested inside other elements.
The five alert types
> [!NOTE]
> Useful information that users should know.
> [!TIP]
> Helpful advice for doing things better.
> [!IMPORTANT]
> Key information users need to succeed.
> [!WARNING]
> Urgent info to avoid problems.
> [!CAUTION]
> Risks or negative outcomes of an action.Note Useful information that users should know.
Tip Helpful advice for doing things better.
Important Key information users need to succeed.
Warning Urgent info to avoid problems.
Caution Risks or negative outcomes of an action.
Outside github.com (and GitLab, which copied the syntax) the text [!NOTE] is shown literally inside a plain blockquote, which is what the preview approximates.
Footnotes
Reference and definition
GFM is a superset of CommonMark.[^1]
[^1]: Per the GFM spec, version 0.29-gfm.
A second line needs two leading spaces.Definitions render at the bottom of the page wherever you put them. Not supported in GitHub wikis, and not part of the GFM spec itself.
Math (LaTeX)
Inline and block math
Inline: $\sqrt{3x-1}+(1+x)^2$ or $`\sqrt{3x-1}`$ when the expression clashes with markdown.
$$
\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right)
$$
```math
\frac{a}{b}
```Rendered with MathJax in issues, discussions, PRs, wikis and .md files. A literal dollar on the same line as math must be written <span>$</span>100; inside math use \$.
Mermaid and other diagrams
Mermaid flowchart
```mermaid
graph TD
A[Push] --> B{CI green?}
B -->|yes| C[Merge]
B -->|no| D[Fix]
```GitHub also renders ```geojson and ```topojson as maps and ```stl as a 3D model. Put `info` in a mermaid block to see which Mermaid version GitHub runs.
Emoji shortcodes
:shortcode:
Ship it :shipit: :+1: :tada:Typing : opens an autocomplete on github.com. Shortcodes are a GitHub feature, not markdown — CommonMark renderers print the colons.
HTML that GitHub keeps
Collapsible section
<details>
<summary>Tips for collapsed sections</summary>
Markdown **works** here after a blank line.
</details>Add open to <details open> to start expanded. GitHub filters <script>, <style>, <iframe>, <title>, <textarea>, <xmp>, <noembed>, <noframes> and <plaintext> (the tagfilter extension).
Hidden comment
<!-- Reviewers: this paragraph is hidden in the rendered README -->
Visible text.Hidden in the rendered page but present in the source — anyone who opens the raw file sees it.
Line breaks and escaping
Line break in a .md file
Two trailing spaces
or a backslash\
or <br/> end a line.Two trailing spaces
or a backslash
or a br tag end a line.
In issues, PRs and discussions a single newline is already a line break; in .md files it is not, so you need one of the three forms.
Escaping
\*not italic\*, \#not-a-heading, \[not a link\]*not italic*, #not-a-heading, [not a link]
A backslash disables the next markdown character. Escaping does not work in issue or PR titles.
Alert types on GitHub
| First line of the blockquote | Use it for | Rendered as |
|---|---|---|
> [!NOTE] | Useful information that users should know, even when skimming content. | Blue, info icon |
> [!TIP] | Helpful advice for doing things better or more easily. | Green, lightbulb icon |
> [!IMPORTANT] | Key information users need to know to achieve their goal. | Purple, report icon |
> [!WARNING] | Urgent info that needs immediate user attention to avoid problems. | Yellow, alert icon |
> [!CAUTION] | Advises about risks or negative outcomes of certain actions. | Red, stop icon |
Fence language tags GitHub highlights
GitHub uses Linguist to pick a highlighter; any language name or alias from its list works. The ones that show up most in READMEs:
| Tag | Also accepted | Language |
|---|---|---|
```js | javascript, node | JavaScript |
```ts | typescript | TypeScript |
```jsx | — | JSX |
```tsx | — | TSX |
```python | py, python3 | Python |
```java | — | Java |
```c | — | C |
```cpp | c++ | C++ |
```csharp | cs, c# | C# |
```go | golang | Go |
```rust | rs | Rust |
```ruby | rb | Ruby |
```php | — | PHP |
```swift | — | Swift |
```kotlin | kt | Kotlin |
```bash | sh, shell, zsh | Shell |
```powershell | ps1, pwsh | PowerShell |
```sql | — | SQL |
```html | xhtml | HTML |
```css | — | CSS |
```json | jsonc, json5 | JSON |
```yaml | yml | YAML |
```toml | — | TOML |
```markdown | md | Markdown |
```diff | patch | Diff (adds +/− colouring) |
```mermaid | — | Rendered as a diagram, not highlighted |
```math | — | Rendered as LaTeX, not highlighted |
What is GitHub Flavored Markdown?
GitHub Flavored Markdown (GFM) is the dialect of markdown GitHub uses for READMEs, issues, pull requests, discussions and wikis. The GFM spec (version 0.29-gfm) is a strict superset of CommonMark that adds five extensions: tables, task list items, strikethrough, extended autolinks and a filter for disallowed raw HTML. On top of the spec, github.com renders footnotes, alerts, math, mermaid, emoji shortcodes, @mentions and issue references.
What is the difference between GFM and CommonMark?
CommonMark is the base specification: headings, emphasis, lists, links, images, code, blockquotes and raw HTML. GFM adds tables, task lists, strikethrough, bare-URL autolinks and the tagfilter that neutralises <script>, <style>, <iframe> and similar tags. Everything valid in CommonMark renders identically in GFM.
Does GFM support footnotes?
GitHub.com renders footnotes (text[^1] with a [^1]: definition), but they are not part of the GFM spec, and they do not work in GitHub wikis. Other renderers that claim GFM support (remark-gfm, GitLab, many static site generators) usually include them, but check before relying on it.
How do I write an alert or callout in GitHub markdown?
Start a blockquote with one of [!NOTE], [!TIP], [!IMPORTANT], [!WARNING] or [!CAUTION] on its own line, then continue the quote with the message. GitHub renders a coloured box with an icon. The docs recommend one or two per article, never consecutive, and alerts cannot be nested inside lists or other elements.
Can I write LaTeX math in a GitHub README?
Yes. Inline math goes between single dollar signs ($x^2$) or $`…`$ when the expression contains markdown characters; block math goes between $$ delimiters on their own lines or in a ```math fence. GitHub uses MathJax and renders it in .md files, issues, PRs, discussions and wikis.
Which diagrams render on GitHub?
Mermaid (```mermaid), GeoJSON and TopoJSON maps (```geojson, ```topojson) and ASCII STL 3D models (```stl), in the same places as math: issues, discussions, PRs, wikis and markdown files. PlantUML, Graphviz and D2 do not render natively.
Why does my markdown look different on GitHub than in my editor?
Usually one of four things: alerts and emoji shortcodes are github.com features that editors show as literal text; GitHub inserts a line break for every newline in issues and PRs but not in .md files; GitHub strips <script>, <style> and <iframe>; and heading anchors follow GitHub's own slug rules, so a table of contents built for another tool can point at the wrong ids.
Related tools and sheets
Check a README before pushing with the GitHub README viewer, scaffold one with the README generator or README templates, add badges, lint it with markdown lint, and compare GFM with every other dialect on the markdown flavors page. The general markdown cheat sheet covers the CommonMark core.