Markdown Cheatsheet

Complete Markdown and GFM cheatsheet covering headings, emphasis, lists, links, tables, code blocks, task lists, footnotes, and MDX extras.

Updated September 15, 2026

markdownmdxgfmdocumentationwriting

Headings

markdown
# H1
## H2
### H3
#### H4
##### H5
###### H6

Alternate syntax for H1 and H2:

markdown
Heading 1
=========

Heading 2
---------

Emphasis

SyntaxResult
**bold** or __bold__bold
*italic* or _italic_italic
***bold italic***bold italic
~~strikethrough~~strikethrough
`inline code`inline code
<mark>highlight</mark>highlight (HTML)
<sub>subscript</sub>subscript (HTML)
<sup>superscript</sup>superscript (HTML)

Lists

Unordered

markdown
- Item one
- Item two
  - Nested item (indent 2 spaces)
  - Another nested
- Item three

Use -, *, or + interchangeably (pick one and stay consistent).

Ordered

markdown
1. First
2. Second
3. Third

1. Lazy numbering (all 1.)
1. Markdown increments automatically
1. So this works too

Task Lists (GFM)

markdown
- [x] Completed task
- [ ] Open task
- [ ] Another open task

markdown
[Link text](https://example.com)
[Link with title](https://example.com "Hover title")
<https://example.com>            (autolink)
<email@example.com>              (email autolink)

[Reference link][ref-id]
[ref-id]: https://example.com "Optional title"

[Implicit reference][]
[Implicit reference]: https://example.com

Images

markdown
![Alt text](https://example.com/image.png)
![Alt text](./local.png "Optional title")

[![Clickable image](image.png)](https://link.com)

[Reference image][img-ref]
[img-ref]: https://example.com/image.png "Title"

Code

Inline

markdown
Use `code` for inline code.

Fenced Blocks

markdown
```python
def hello():
    print("Hello, world!")
```

Common language identifiers: python, typescript, javascript, bash, sh, sql, json, yaml, dockerfile, rust, go, html, css, markdown.

Indented Code (4 spaces)

markdown
    This is a code block
    indented with 4 spaces

Tables (GFM)

markdown
| Column 1 | Column 2 | Column 3 |
|---|---|---|
| Cell 1 | Cell 2 | Cell 3 |
| Cell 4 | Cell 5 | Cell 6 |

Alignment with colons:

markdown
| Left | Center | Right |
|:---|:---:|---:|
| text | text | text |

Blockquotes

markdown
> Single level quote

> First level
>> Nested quote
>>> Triple nested

> **Tip:** You can include *emphasis* and `code` in blockquotes.

Horizontal Rules

markdown
---
***
___

All three produce a horizontal rule. Leave blank lines before and after.


Escaping Special Characters

Backslash-escape these characters: \ * _ { } [ ] ( ) # + - . !

markdown
\*literal asterisks\*
\[not a link\]

HTML in Markdown

Most Markdown processors allow inline HTML:

markdown
<details>
  <summary>Click to expand</summary>

  Hidden content here.
</details>

<kbd>Ctrl</kbd>+<kbd>C</kbd>

GFM Extras (GitHub Flavored Markdown)

Footnotes

markdown
Here is a sentence with a footnote.[^1]

[^1]: This is the footnote text.

Strikethrough

markdown
~~deleted text~~
markdown
Visit https://github.com directly (no brackets needed in GFM).

Mention and Issue References (GitHub only)

markdown
@username
#123
org/repo#456
commit SHA: abc1234

MDX Extras (for .mdx files)

MDX allows importing and using React components inside Markdown:

mdx
import { Chart } from './Chart'

# My Document

Regular markdown content.

<Chart data={[1, 2, 3]} title="My Chart" />

More markdown after the component.

Frontmatter (YAML, parsed by most static site generators)

yaml
---
title: My Page
date: '2026-01-01'
tags: ['markdown', 'mdx']
draft: false
---

Expressions

mdx
The current year is {new Date().getFullYear()}.

Markdown Flavors Comparison

FeatureStandardGFMMDX
TablesNoYesYes
Task listsNoYesYes
StrikethroughNoYesYes
FootnotesNoYesYes
AutolinksNoYesYes
JSX componentsNoNoYes
Expressions {}NoNoYes
FrontmatterNoNoYes (via plugin)

GitHub Flavored Markdown (GFM) Alerts

GitHub and modern markdown parsers natively render blockquote alerts with dedicated color styling:

markdown
> [!NOTE]
> Useful information that users should know, even when skimming content.

> [!TIP]
> Helpful advice for doing things better, faster, or more efficiently.

> [!IMPORTANT]
> Key information users need to know to achieve their goal.

> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.

> [!CAUTION]
> Advises about risks, destructive actions, or negative outcomes.

Collapsible Accordion Sections (HTML Details)

Use native HTML <details> and <summary> tags to hide large logs, stack traces, or optional walkthroughs:

markdown
<details>
  <summary>Click to expand configuration file</summary>

```json
{
  "name": "production-service",
  "port": 8080,
  "env": "production"
}
```

</details>

Mathematical Notation (LaTeX / KaTeX)

Standard mathematical notation rendered using double dollar signs for block equations and single dollar signs for inline math:

markdown
Inline equation: $E = mc^2$

Block equation:
$$
\sigma(z) = \frac{1}{1 + e^{-z}}
$$

Matrices and systems of equations:
$$
\begin{bmatrix}
a & b \\
c & d
\end{bmatrix}
\begin{bmatrix}
x \\
y
\end{bmatrix}
=
\begin{bmatrix}
ax + by \\
cx + dy
\end{bmatrix}
$$

Diagramming with Mermaid

Modern Markdown engines (like GitHub, GitLab, and documentation portals) render diagrams directly from code:

markdown
```mermaid
graph TD
    A[Client Request] --> B{Edge Middleware}
    B -->|Authenticated| C[Next.js SSR Origin]
    B -->|Unauthorized| D[Redirect to Login]
    C --> E[(PostgreSQL)]