Markdown Cheat Sheet
Every Markdown syntax you’ll need, with copy-ready examples. Works with CommonMark and GitHub Flavored Markdown (GFM).
Last updated
Markdown is a lightweight way to format plain text. Type the syntax on the left and it renders as the result on the right. You can try every example below in Markdown Viewer Online, which shows a live preview as you type.
Headings
Start a line with one to six # characters, followed by a space.
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
Paragraphs and line breaks
Separate paragraphs with a blank line. For a line break inside a paragraph, end the line with two spaces or a backslash (\).
This is the first paragraph.
This is the second paragraph.
This line ends with a backslash\
so this text starts on a new line.
Emphasis
| Style | Markdown | Result |
|---|---|---|
| Bold | **bold text** |
bold text |
| Italic | *italic* or _italic_ |
italic |
| Bold and italic | ***both*** |
both |
| Strikethrough (GFM) | ~~deleted~~ |
|
| Inline code | `code` |
code |
Lists
Bulleted lists
Start each line with -, * or +. Indent by two or more spaces to nest.
- Apples
- Oranges
- Blood oranges
- Navel oranges
- Pears
Numbered lists
The numbers you type don’t have to be in order — the first number sets the starting point.
1. First step
2. Second step
3. Third step
Task lists (GFM)
- [x] Write the draft
- [ ] Review it
- [ ] Publish
In Markdown Viewer Online you can tick the boxes in the preview and the Markdown updates automatically.
Links
[Link text](https://example.com)
[Link with a title](https://example.com "Shown on hover")
<https://example.com>
https://example.com
The last two become links automatically (the bare URL works in GitHub Flavored Markdown).
Reference-style links
Read the [CommonMark spec][spec] for details.
[spec]: https://spec.commonmark.org/
Links to headings
Every heading gets an anchor made from its text in lower case, with spaces replaced by hyphens:
[Jump to Tables](#tables)
Images


Always write alt text — it is read aloud by screen readers and shown if the image can’t load. To control the size, use HTML: <img src="photo.jpg" width="300" alt="…">.
Blockquotes
> Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
>
> > Quotes can be nested.
Alerts (GitHub)
Highlight important information with a blockquote whose first line is [!NOTE], [!TIP], [!IMPORTANT], [!WARNING] or [!CAUTION].
> [!NOTE]
> Useful information users should know.
> [!WARNING]
> Urgent info that needs immediate attention.
Code
Wrap inline code in single backticks. For blocks, use three backticks (a “fenced code block”) and add the language name for syntax highlighting:
```python
def greet(name):
return f"Hello, {name}!"
```
Indenting every line by four spaces also creates a code block, but fences are clearer and support highlighting.
Tables (GFM)
Use pipes | to separate columns and a row of hyphens under the header. Colons set the alignment.
| Left aligned | Centred | Right aligned |
| :----------- | :-----: | ------------: |
| Apple | 12 | $1.20 |
| Banana | 7 | $0.50 |
| Left aligned | Centred | Right aligned |
|---|---|---|
| Apple | 12 | $1.20 |
| Banana | 7 | $0.50 |
To use a pipe character inside a cell, escape it: \|.
Horizontal rule
Three or more hyphens, asterisks or underscores on their own line:
---
Footnotes
Here is a sentence with a footnote.[^1]
[^1]: And here is the footnote text.
Maths (KaTeX)
Write LaTeX maths between dollar signs. Markdown Viewer Online renders it with KaTeX.
Inline: $E = mc^2$
Block:
$$
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
$$
Diagrams (Mermaid)
Draw flowcharts, sequence diagrams, Gantt charts and more with a mermaid code block:
```mermaid
flowchart LR
A[Idea] --> B[Draft] --> C{Approved?}
C -- Yes --> D[Publish]
C -- No --> B
```
HTML in Markdown
Most Markdown renderers allow simple HTML for things Markdown can’t do:
<details>
<summary>Click to expand</summary>
Hidden content goes here.
</details>
Press <kbd>Ctrl</kbd> + <kbd>S</kbd> to save.
For safety, Markdown Viewer Online removes scripts and other unsafe HTML from documents before showing them.
Escaping characters
Put a backslash before a character to show it literally instead of formatting: \*not italic\*, \# not a heading, \[not a link\].
Characters you can escape with a backslash:
\ ` * _ { } [ ] ( ) # + - . ! |