Skip to main content

Markdown Cheat Sheet

Basic, extended, and GitHub Markdown syntax on one page. Every snippet has a copy button and a preview, and a label that says where it renders.

Short answer

Markdown formats plain text with symbols: # Heading, **bold**, *italic*, [text](url), - list item, > quote, and backticks for `code`. Those are CommonMark and work almost everywhere. Tables, task lists, and ~~strikethrough~~ are GitHub Flavored Markdown extensions, while footnotes, highlights, and definition lists are extended syntax that only some apps render.

  • CommonMarkCore Markdown. Works in almost every renderer.
  • GFMGitHub Flavored Markdown extension. GitHub, GitLab, Obsidian, and most modern renderers.
  • ExtendedOnly some apps. Plain text everywhere else.
  • HTMLRaw HTML. Works where the renderer allows HTML, not in chat apps.
  • GitHubGitHub.com features beyond the GFM spec.

Markdown Syntax at a Glance

Every element in one table. The sections below have a copy button and a rendered preview for each.

Markdown syntax quick reference and where each syntax works
ElementMarkdownWorks in
Heading# H1 ## H2 ### H3CommonMark
Bold**bold**CommonMark
Italic*italic*CommonMark
Strikethrough~~text~~GFM
Link[text](https://example.com)CommonMark
Image![alt text](image.jpg)CommonMark
Bulleted list- itemCommonMark
Numbered list1. itemCommonMark
Task list- [ ] taskGFM
Blockquote> quoteCommonMark
Inline code`code`CommonMark
Code block```lang … ```CommonMark
Table| a | b | then |---|---|GFM
Horizontal rule---CommonMark
Line breakend the line with \CommonMark
Footnotetext[^1] then [^1]: noteExtended
Highlight==text==Extended
Underline<ins>text</ins>HTML
Comment<!-- hidden -->HTML
Collapsible section<details><summary>…HTML
Alert> [!NOTE]GitHub

Start a line with one to six # characters and a space. More # characters make a smaller heading. The space is required: #Heading stays plain text.

Heading 1 (page title, use once)CommonMark
# Heading 1
Preview
Heading 2 (section)CommonMark
## Heading 2
Preview
Heading 3 (subsection)CommonMark
### Heading 3
Preview
Heading 4CommonMark
#### Heading 4
Preview
Heading 5CommonMark
##### Heading 5
Preview
Heading 6 (smallest)CommonMark
###### Heading 6
Preview
Alternative: underline with = for level 1 or - for level 2CommonMark
Heading 2
---------
Preview

Text Formatting

Bold guide

Wrap text in asterisks or underscores. Strikethrough is a GFM extension, and Markdown has no underline syntax at all.

BoldCommonMark
**bold text**
Preview
ItalicCommonMark
*italic text*
Preview
Underscore versions (they do not work in the middle of a word)CommonMark
__bold__ and _italic_
Preview
Bold and italic togetherCommonMark
***bold and italic***
Preview
StrikethroughGFM
~~strikethrough~~
Preview
Underline (no Markdown syntax; GitHub documents <ins>)HTML
<ins>underlined</ins>
Preview

Same as a link with a ! in front. The text in brackets is the alt text screen readers announce.

ImageCommonMark
![Alt text](image.jpg)
Preview
Image with a title (a hover tooltip, not a visible caption)CommonMark
![Alt text](image.jpg "Title")
Preview
Clickable image (an image inside a link)CommonMark
[![Alt text](image.jpg)](https://example.com)
Preview
Set a size (Markdown has no width syntax)HTML
<img src="image.jpg" alt="Alt text" width="300">
Preview

Start lines with -, *, or + for bullets, or a number and a period for steps. To nest, indent the item to line up with the parent's text: 2 spaces under -, 3 under 1.

Bulleted list (-, *, or +)CommonMark
- Apple
- Banana
- Cherry
Preview
Numbered list (numbering starts from the first number)CommonMark
1. First step
2. Second step
3. Third step
Preview
Nested bullets (2-space indent)CommonMark
- Fruits
  - Apple
  - Banana
- Vegetables
  - Carrot
Preview
Nested under a numbered item (3-space indent)CommonMark
1. First step
   - A detail
2. Second step
Preview

A GFM extension: [ ] for open, [x] for done. On GitHub the boxes are clickable in issue and pull request comments and read-only in a rendered .md file.

[x] = checked, [ ] = uncheckedGFM
- [x] Write documentation
- [x] Push to GitHub
- [ ] Deploy to production
- [ ] Celebrate 🎉
Preview

Blockquotes

Quotes guide

Start each line with >. Lines in one quote join into a single paragraph, so use an empty > line to start a new one.

BlockquoteCommonMark
> This is a quote.
Preview
Two lines join into one paragraph; the empty > line splits the attributionCommonMark
> "The only way to do great work
> is to love what you do."
>
> — Steve Jobs
Preview
Nested blockquoteCommonMark
> Note: Important information
>> Warning: Be careful here
Preview

Backticks for code inside a sentence, three backticks (or three tildes) on their own lines for a block. The word after the opening fence names the language for syntax highlighting.

Inline codeCommonMark
`const x = 42;`
Preview
Inline code that contains a backtick (wrap it in two)CommonMark
``Use `code` here``
Preview
Fenced code block with a languageCommonMark
```javascript
function greet(name) {
  return `Hello, ${name}!`;
}
```
Preview
Fenced code block, PythonCommonMark
```python
def greet(name):
    return f"Hello, {name}!"
```
Preview
Fenced code block, no languageCommonMark
```
No language specified
Plain code block
```
Preview

A GFM extension. The row of dashes under the header is required, colons in it set alignment, and a literal pipe inside a cell is written \|.

TableGFM
| Name    | Role      |
|---------|-----------|
| Alice   | Developer |
| Bob     | Designer  |
Preview
Column alignment with colonsGFM
| Left   | Center  | Right  |
|:-------|:-------:|-------:|
| L      |    C    |      R |
| Text   |  Text   |   Text |
Preview

Horizontal Rules

Horizontal rules guide

Three or more -, *, or _ on a line by themselves. Leave a blank line above ---, or the text above it becomes a heading.

Three dashesCommonMark
---
Preview
Three asterisksCommonMark
***
Preview
Three underscoresCommonMark
___
Preview

Line Breaks & Paragraphs

Line breaks guide

In CommonMark and GFM files a single Enter does not start a new line. End the line with a backslash or two spaces, or leave a blank line for a new paragraph.

One Enter: the lines join (GitHub comments, Discord, and Slack keep the break)CommonMark
Line one
Line two
Preview
Line break: backslash at the end of the lineCommonMark
Line one\
Line two
Preview
Line break: two spaces at the end (·· = spaces, copied as real spaces)CommonMark
Line one··
Line two
Preview
New paragraph: blank lineCommonMark
Paragraph one.

Paragraph two.
Preview
HTML line break (also works inside table cells)HTML
Line one<br>Line two
Preview

Escaping Characters

Put a backslash in front of any ASCII punctuation character to show it literally instead of formatting with it.

Literal asterisksCommonMark
\*not italic\*
Preview
Literal hash at the start of a lineCommonMark
\# Not a heading
Preview
Literal bracketsCommonMark
\[Not a link\](url)
Preview
Stop a line starting with a number from becoming a listCommonMark
1986\. A great year.
Preview

Extended Syntax

Footnotes guide

Not part of CommonMark or the GFM spec. Each one renders only in the apps named; everywhere else the characters show up as plain text.

Footnote: GitHub, Obsidian, PandocExtended
Here is a sentence with a footnote.[^1]

[^1]: This is the footnote.
Preview
Highlight: Obsidian and some editors (GitHub shows the = signs; use <mark>)Extended
==highlighted text==
Preview
Custom heading ID: Pandoc, kramdown, PHP Markdown Extra (GitHub prints {#custom-id} as text)Extended
### My Heading {#custom-id}
Preview
Definition list: Pandoc, kramdown, PHP Markdown Extra (not GitHub or Obsidian)Extended
Term
: Definition of the term
Preview
Subscript and superscript: Pandoc, R Markdown (on GitHub, ~2~ is strikethrough)Extended
H~2~O and X^2^
Preview
Emoji shortcodes: GitHub, plus the Slack and Discord message boxesExtended
:tada: :+1:
Preview
Where extended Markdown syntax renders
SyntaxGitHubObsidianAlso in
Footnotes [^1]Yes (not in wikis)YesPandoc, MultiMarkdown, PHP Markdown Extra
Highlight ==text==No, use <mark>YesTypora (when enabled)
Heading ID {#id}No, IDs are automaticNoPandoc, kramdown, PHP Markdown Extra
Definition listNoNoPandoc, kramdown, PHP Markdown Extra
Sub/superscript ~ ^No, use <sub>/<sup>No, use <sub>/<sup>Pandoc, R Markdown
Emoji :shortcode:YesNo (plugins exist)Slack, Discord message boxes
Alerts > [!NOTE]YesYes, as calloutsVaries by tool; check yours

Beyond CommonMark and GFM, GitHub renders footnotes, emoji shortcodes, and the features below. In issues, pull requests, and comments a single Enter is a line break; in .md files it is not.

Alert: NOTE, TIP, IMPORTANT, WARNING, or CAUTION (Obsidian renders these as callouts)GitHub
> [!NOTE]
> Useful information readers should know.
Preview
Collapsible section (keep the blank lines so the Markdown inside renders)HTML
<details>
<summary>Click to expand</summary>

Hidden content with **Markdown**.

</details>
Preview
Math: $…$ inline, $$…$$ for a blockGitHub
The area is $\pi r^2$.
Preview
Subscript and superscript with HTML tags GitHub allowsHTML
H<sub>2</sub>O and x<sup>2</sup>
Preview
Mention and issue link (issues, pull requests, and comments; plain text in .md files)GitHub
@octocat can you review #123?
Preview

Common Mistakes

The six slips behind most "my Markdown isn't working" questions, checked against the CommonMark and GFM specs.

No space after #

Wrong

#Heading

Right

# Heading

CommonMark needs a space after the # characters. Without it the line stays plain text.

Dashes right under a line of text

Wrong

Some text
---

Right

Some text

---

Dashes directly under text turn that text into a level 2 heading. A blank line above makes a rule.

Expecting Enter to start a new line

Wrong

Line one
Line two

Right

Line one\
Line two

In .md files the two lines join into one. End the first line with a backslash.

Two spaces under a numbered item

Wrong

1. Step
  - Detail

Right

1. Step
   - Detail

A nested item has to line up with the parent's text, which starts 3 characters in after "1. ".

Tilde subscript on GitHub

Wrong

H~2~O

Right

H<sub>2</sub>O

GitHub treats a single pair of tildes as strikethrough, so the 2 gets crossed out.

A table without the dash row

Wrong

| a | b |
| 1 | 2 |

Right

| a | b |
|---|---|
| 1 | 2 |

Without the delimiter row under the header, GFM renders the pipes as plain text.

Frequently Asked Questions

What is the basic syntax of Markdown?

Headings (# Heading), bold (**text**), italic (*text*), links ([text](url)), images (![alt](url)), lists (- item or 1. item), blockquotes (> text), inline code (`code`), fenced code blocks (```), and horizontal rules (---). These come from the original 2004 syntax, and the CommonMark spec defines them precisely, so they render the same almost everywhere.

What is the difference between basic and extended Markdown syntax?

Basic syntax is what the original Markdown and the CommonMark spec define. Extended syntax was added later by specific flavors: GitHub Flavored Markdown adds tables, task lists, strikethrough, and bare-URL autolinks, and other tools add footnotes, highlights, definition lists, custom heading IDs, and emoji shortcodes. Extended syntax only renders in apps that support it.

Does GitHub support everything on this cheat sheet?

GitHub supports every CommonMark and GFM row, plus footnotes, emoji shortcodes, alerts, math, and the HTML tags shown here (<ins>, <sub>, <sup>, <details>, <mark>). It does not support ==highlight==, definition lists, custom {#heading-ids}, or H~2~O subscript. A single pair of tildes is strikethrough on GitHub.

How do I make a new line in Markdown?

End the line with a backslash (\) or two spaces, or leave a blank line to start a new paragraph. A single Enter is ignored in CommonMark and GFM files, so the two lines join. GitHub comments, Discord, and Slack are the exceptions: there, Enter does start a new line.

How do I underline text in Markdown?

Markdown has no underline syntax, and underscores make italics. Where HTML is allowed, use <ins>text</ins>, the tag GitHub documents for underlining. Discord is the exception: __text__ underlines there.

Why is my Markdown not formatting?

Usually one of four things: the app does not parse Markdown at all (or not that syntax), a required space is missing (#Heading, -item), a GFM or extended feature is used in a renderer that only supports CommonMark, or the text sits inside a code block. Check the label on each row above to see where a syntax works.

Can I download or print this Markdown cheat sheet?

Use your browser's print dialog (Ctrl+P or Cmd+P) and choose Save as PDF. To turn your own Markdown file into a PDF, use the free Markdown to PDF converter on this site.