Markdown cheat sheet: basic and extended syntax with examples

Every Markdown syntax on one page: headings, lists, links, images, code, tables, task lists, footnotes, alerts, math and Mermaid, with examples.

Basic syntax

These work in every Markdown app, because they are part of CommonMark, the core standard.

ElementMarkdown
Heading 1 to 6# Title, ## Section … ###### Level 6
Bold**bold**
Italic*italic* or _italic_
Bold and italic***both***
Inline code`code`
Link[text](https://example.com)
Link with a title[text](https://example.com "Title")
Image![Alt text](image.png)
Blockquote> Quoted text
Horizontal rule--- on its own line
Line breaktwo spaces or \ at the end of the line
Escape a symbol\*, \#, \_

A blank line separates paragraphs. Put a space after # in headings: #Title is plain text in CommonMark.

Lists

Markdown
- Bullet item
- Another item
  - Nested item (indent two spaces)

1. First step
2. Second step
   1. Nested step (indent under the text)

- [ ] Task to do
- [x] Task done

Bullets can use -, * or +; keep one marker per list. Numbered lists only need the first number right: 1. on every line still counts 1, 2, 3. Task lists (- [ ]) are part of GitHub Flavored Markdown.

Links and images

Markdown
[Inline link](https://example.com)
[Relative link to another file](docs/setup.md)
[Link to a heading](#installation)
<https://example.com>

[Reference link][docs]

[docs]: https://example.com/docs

![A diagram of the build](images/build.png)
[![Image that links](badge.svg)](https://example.com)

Relative links and image paths are resolved from the folder of the current file, so keep linked files where the links expect them. If images don't appear, see local Markdown images not showing; for links between files, see relative Markdown links.

Code

Inline code uses single backticks. For a block, fence it with three backticks and name the language for syntax highlighting:

Markdown
```python
def greet(name):
    return f"Hello, {name}"
```

To show backticks inside inline code, wrap it in double backticks: `` `code` ``. To show a fenced block inside a fenced block, use four backticks for the outer fence, as above.

Extended syntax (GitHub Flavored Markdown)

GitHub Flavored Markdown adds these to CommonMark. GitHub, GitLab, VS Code, Obsidian, Typora and most Markdown readers support them.

ElementMarkdown
Strikethrough~~deleted~~
Task list- [ ] to do, - [x] done
Autolinkhttps://example.com written as plain text
FootnoteClaim.[^1] and, anywhere, [^1]: The source.
Tableheader row, separator row, data rows

A table looks like this:

Markdown
| Plan | Price | Projects |
| :--- | ----: | :------: |
| Free |    $0 |    3     |
| Pro  |   $12 | No limit |

Colons in the separator row set alignment. For escaping pipes, line breaks in cells and converting spreadsheets, see the Markdown table syntax guide, or build one in the Markdown table generator.

Alerts, math and diagrams

These are extensions supported by some apps and not others. Check where your file will be read.

Alerts (GitHub and some readers, including Aero Markdown):

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

> [!WARNING]
> Something that needs attention.

The five types are NOTE, TIP, IMPORTANT, WARNING and CAUTION; see GitHub alerts in Markdown.

Math with LaTeX between dollar signs: $E = mc^2$ inline, $$ on the lines around a display equation. The LaTeX cheat sheet lists the commands.

Diagrams with Mermaid in a fenced block named mermaid:

Markdown
```mermaid
flowchart LR
  Draft --> Review --> Publish
```

See the Mermaid flowchart syntax and sequence diagram guides.

HTML inside Markdown

Most renderers accept some HTML where Markdown has no syntax, such as <details> for a collapsible section, <kbd> for keys or <sup> for superscript. Many also remove HTML they consider unsafe, and some show it as text. Use HTML sparingly, and only where you know the renderer.

Try it and convert it

The free tools on this site convert Markdown in both directions:

All of them are listed on the free Markdown tools page.

Frequently asked questions

What is Markdown?

Markdown is a plain-text format for writing structured documents. Symbols such as # for headings and ** for bold stay readable as text, and a Markdown app renders them as formatting. Files usually end in .md.

What is the difference between CommonMark and GitHub Flavored Markdown?

CommonMark is the standard specification of core Markdown: headings, emphasis, lists, links, images, code and quotes. GitHub Flavored Markdown (GFM) builds on it and adds tables, task lists, strikethrough, autolinks and footnotes.

How do I make a line break in Markdown?

A single line break inside a paragraph is ignored. End the line with two spaces or a backslash to force a break, or leave a blank line to start a new paragraph.

How do I underline text in Markdown?

Markdown has no underline syntax. Use bold or italics instead; where HTML is allowed, <ins>text</ins> underlines text, but many renderers strip it.

How do I show a literal asterisk or hash in Markdown?

Put a backslash before it: \* or \#. The backslash escapes any Markdown punctuation character, including _ [ ] ( ) ` and |.

How do I preview Markdown without installing anything?

Paste it into a browser viewer such as the free online Markdown viewer on aeromarkdown.app. It renders headings, tables and code in the tab without uploading the text.