Markdown cheat sheet

Updated

Every markdown element with the syntax on the left and the rendered result on the right. Covers core markdown, GitHub Flavored Markdown (GFM), alerts, emoji, anchor links and mermaid diagrams. Click Copy on any block to grab the snippet.

Download printable PDFOne file, every snippet on this page. Or press Ctrl/Cmd+P — the page has print styles.

Headings

Six levels

# H1 — page title
## H2 — section
### H3 — subsection
#### H4
##### H5
###### H6

H1 — page title

H2 — section

H3 — subsection

H4

H5
H6

One H1 per document is the convention. The alternative "underline" syntax (=== / ---) only covers H1 and H2 — the # form is preferred.

Emphasis

Bold, italic, both

**bold** and *italic* and ***bold italic***

bold and italic and bold italic

Underscores work too (__bold__, _italic_), but asterisks survive mid-word: fan**tas**tic.

Strikethrough (GFM)

~~crossed out~~

crossed out

Lists

Unordered

- First item
- Second item
  - Nested (indent 2 spaces)
- Third item
  • First item
  • Second item
    • Nested (indent 2 spaces)
  • Third item

Nested list guide: indentation rules →

Ordered

1. Step one
2. Step two
1. The numbers you type don't matter — renderers count for you
  1. Step one
  2. Step two
  3. The numbers you type don't matter — renderers count for you

Numbered list guide: restarting and continuing numbers →

Task list (GFM)

- [x] Ship the feature
- [ ] Write the docs
- [ ] Tell someone
  • Ship the feature
  • Write the docs
  • Tell someone

Code

Inline code

Run `npm install` before `npm run dev`.

Run npm install before npm run dev.

Fenced block with language

```ts
function greet(name: string) {
  return `Hello, ${name}`;
}
```
function greet(name: string) {
  return `Hello, ${name}`;
}

The language tag after ``` turns on syntax highlighting. Common tags: js, ts, python, bash, json, sql, diff.

Fence inside a fence

````md
To show a code block inside a code block,
use more backticks on the outside:
```js
console.log("nested");
```
````

Tables (GFM)

Basic table with alignment

| Left | Center | Right |
| :--- | :----: | ----: |
| a    |   b    |     c |
| d    |   e    |     f |
LeftCenterRight
abc
def

Colons in the separator row control alignment. Escape literal pipes in cells as \|. Need to build one fast? Use the table generator below.

Table guide: alignment, line breaks inside cells, wide tables →

Blockquotes

Quote and nesting

> A quoted paragraph.
>
> > Nested quotes work too.
>
> Back to the first level — **formatting works inside**.

A quoted paragraph.

Nested quotes work too.

Back to the first level — formatting works inside.

Prefix every line with > (a lone > keeps a multi-paragraph quote together). GitHub turns > [!NOTE] / [!WARNING] quotes into coloured alerts.

Full blockquote guide: attribution, alerts, Discord/Slack quirks →

Alerts (GitHub)

A blockquote whose first line is [!TYPE] renders as a coloured callout on GitHub. Five types: NOTE, TIP, IMPORTANT, WARNING, CAUTION.

The five alert types

> [!NOTE]
> Useful information the reader should know.

> [!TIP]
> Advice for doing something better.

> [!IMPORTANT]
> Key information needed to succeed.

> [!WARNING]
> Urgent info that needs immediate attention.

> [!CAUTION]
> Negative consequences of an action.

Note Useful information the reader should know.

Tip Advice for doing something better.

Important Key information needed to succeed.

Warning Urgent info that needs immediate attention.

Caution Negative consequences of an action.

Rendered as coloured boxes with icons on GitHub (READMEs, issues, PRs, discussions) and GitLab. Everywhere else — VS Code preview, Slack, Discord, Notion, most static site generators — the literal text "[!NOTE]" shows inside a plain blockquote, which is roughly what the preview on the right approximates.

Alerts guide: every type, nesting and fallbacks →

Structure & spacing

Horizontal rule

Above the line.

---

Below the line.

Above the line.


Below the line.

Three or more hyphens on their own line, with blank lines around them (otherwise --- under text becomes an H2).

Line break vs. new paragraph

End a line with two spaces  
for a line break in the same paragraph.

A blank line starts a new paragraph.

End a line with two spaces
for a line break in the same paragraph.

A blank line starts a new paragraph.

A backslash at the end of a line also forces a break and is easier to see than trailing spaces.

Escaping characters

\*not italic\* and \# not a heading and \| not a table pipe

*not italic* and # not a heading and | not a table pipe

Footnotes (GFM)

Footnote reference and definition

Markdown was created in 2004.[^1]

[^1]: By John Gruber, with Aaron Swartz contributing to the syntax.

Markdown was created in 2004.1

Footnotes

  1. By John Gruber, with Aaron Swartz contributing to the syntax. ↩

Supported on GitHub and most modern renderers; not part of original markdown.

Emoji

Shortcodes and literal emoji

Ship it :tada: :rocket: — or paste the character directly: 🎉 🚀

Shortcodes like :tada: are not markdown: GitHub, GitLab, Slack and Discord expand them; CommonMark renderers, VS Code preview and most static site generators print the colons. Pasting the actual emoji character works everywhere.

Emoji guide: shortcode support matrix →

Mermaid diagrams

Flowchart from a code fence

```mermaid
graph LR
  A[Write markdown] --> B{Share it?}
  B -->|yes| C[Get a link]
  B -->|no| D[Keep local]
```

Supported on GitHub, GitLab, and Docs MD share pages. Also handles sequence diagrams, gantt charts, and ER diagrams.

Inline HTML

When markdown runs out

Markdown has no underline, so use <u>HTML</u>, <sub>subscript</sub>, <sup>superscript</sup>, or <kbd>Ctrl</kbd>+<kbd>C</kbd>.

Markdown has no underline, so use <u>HTML</u>, <sub>subscript</sub>, <sup>superscript</sup>, or <kbd>Ctrl</kbd>+<kbd>C</kbd>.

Most renderers pass HTML through (GitHub sanitizes scripts and styles). The preview on this page strips raw HTML, so check the result on your target platform.

Keyboard keys with <kbd>

Press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> to open the command palette.

GitHub styles <kbd> as a small key cap. There is no markdown-native syntax for keys; backticks (`Ctrl`) are the plain-text fallback that works everywhere.

Collapsible section with <details>

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

Hidden content — **markdown works here** if you leave a blank line after the summary.

</details>

Supported on GitHub, GitLab and most docs sites. Add <details open> to start expanded. Not supported in Slack, Discord or Notion.

Collapsible section guide →

More cheat sheets

Every platform bends markdown a little. These sheets cover what each one renders, what it ignores, and what it invents.

Element guides

One page per element, with every variant and the platforms where it does not work.

Which markdown is this?

"Markdown" in the wild almost always means GitHub Flavored Markdown (GFM) — the original 2004 syntax plus tables, task lists, strikethrough, autolinks, and footnotes. Everything on this page renders on GitHub, GitLab, and on Docs MD share pages. The formal spec behind it is CommonMark; when two renderers disagree about an edge case, CommonMark's answer is the one to bet on. Chat apps are the exception — see the flavor comparison and the dedicated Discord and Slack formatting sheets, and the markdown guides for deep dives on single features.

What is a markdown cheat sheet?

A one-page reference of every markdown element with the syntax and the rendered result side by side, so you can copy the exact characters instead of guessing. This one covers core markdown, GitHub Flavored Markdown (tables, task lists, strikethrough, footnotes), and mermaid diagrams.

How do I make text bold or italic in markdown?

Wrap text in double asterisks for bold (**bold**) and single asterisks or underscores for italic (*italic* or _italic_). Triple asterisks give bold italic. Underscores inside a word do not trigger emphasis on GitHub, so asterisks are the safer default.

How do I add a link or an image?

A link is [text](https://example.com) and an image is the same with a leading exclamation mark: ![alt text](image.png). Add a tooltip with a quoted title after the URL. Reference-style links ([text][id] plus [id]: url on its own line) keep long documents readable.

How do I write a code block?

Put the code between two lines of three backticks. Add a language name right after the opening backticks (```js) to get syntax highlighting. Use single backticks for inline code.

How do I make a table in markdown?

Separate columns with pipes and add a line of dashes under the header row. Colons in that separator line set alignment: :--- left, :---: center, ---: right. Tables are a GFM extension supported by GitHub, GitLab, and most renderers.

What is the difference between Markdown and GitHub Flavored Markdown?

GitHub Flavored Markdown (GFM) is the original markdown plus tables, task lists, strikethrough, autolinks, and footnotes, with a formal spec built on CommonMark. Nearly every modern renderer supports GFM, so it is what people usually mean by "markdown". GitHub itself adds alerts, emoji shortcodes and mermaid on top of GFM.

GitHub Flavored Markdown cheat sheet →

Which Markdown works in Slack, Discord and Notion?

Each one is a different dialect. Discord supports most of the basics (**bold**, *italic*, code fences, headings, quotes) but has no tables or images and uses __underscores__ for underline. Slack is not markdown at all: *single asterisks* are bold, _underscores_ italic, ~tildes~ strikethrough, and [text](url) links only work in the composer with the markup preference on. Notion converts markdown as you type and on paste, including tables and task lists. Check the per-platform sheets before pasting.

Markdown flavors compared →

Put it to work

Build tables visually with the table generator, turn a document into a file with the PDF converter or HTML converter, clean it up with the formatter, scaffold a README with the README generator, or share markdown as a link that renders everything on this page — including the mermaid diagrams.