Markdown Cheat Sheet: Syntax, Tables, Task Lists and Diagrams

6 min read · Published 1 November 2026 · Updated 2 November 2026

Markdown is a plain-text way to write formatted documents. You type simple symbols, and a renderer turns them into headings, lists, links and tables. It is used for README files, documentation, notes and chat messages. This cheat sheet lists the syntax you will use most, including the GitHub-flavoured extensions that most tools support.

Headings and paragraphs

Start a line with one to six # characters for a heading, followed by a space. Separate paragraphs with a blank line. A single line break inside a paragraph is usually joined into one line; to force a line break, end the line with two spaces or a backslash.

Headings

# Heading level 1
## Heading level 2
### Heading level 3

Emphasis

Text styles

*italic* or _italic_
**bold** or __bold__
***bold and italic***
~~strikethrough~~   (GitHub-flavoured)
`inline code`

Lists

Start lines with -, * or + for a bulleted list and with numbers followed by a dot for a numbered list. Indent by two or four spaces to nest items. The actual numbers in a numbered list do not matter; the renderer numbers them in order.

Lists

- First item
- Second item
  - Nested item

1. Step one
2. Step two
3. Step three

Always write meaningful alt text for images. It is shown if the image fails to load and read aloud by screen readers.

Links and images

[Link text](https://example.com "optional title")
![Alt text for the image](image.png)
<https://example.com>   (automatic link)

Blockquotes and horizontal rules

Quotes and rules

> This is a quoted paragraph.
> It can span several lines.

---   (three hyphens make a horizontal rule)

Code blocks

Surround code with three backticks on their own lines. Add the language name after the opening backticks to turn on syntax highlighting.

Fenced code block

```javascript
const total = items.reduce((sum, item) => sum + item.price, 0);
```

Tables (GitHub-flavoured)

Separate columns with pipes and add a row of hyphens under the header. Colons in the separator row set alignment.

Table

| Tool       | Purpose        | Price |
|:-----------|:--------------:|------:|
| Formatter  | Clean up JSON  | Free  |
| Compressor | Shrink images  | Free  |

Task lists

Task lists render as checkboxes and are handy for to-do lists and pull request descriptions.

Task list

- [x] Write the draft
- [ ] Review the draft
- [ ] Publish

Diagrams with Mermaid

Many renderers can draw diagrams from text. Write a fenced code block with the language mermaid and describe the diagram inside.

Mermaid flowchart

```mermaid
flowchart LR
  A[Write Markdown] --> B[Preview]
  B --> C{Looks right?}
  C -- Yes --> D[Publish]
  C -- No --> A
```

Escaping and compatibility

  • To show a special character literally, put a backslash before it, for example \* or \#.
  • Markdown has several flavours. Tables, task lists and strikethrough are extensions that most, but not all, renderers support, so preview your text in the tool where it will be published.
  • Some renderers allow raw HTML inside Markdown and others remove it for safety.

Common pitfalls when writing Markdown

  • No blank line before a list, table or code block. Many renderers will not recognise the structure unless it is separated from the paragraph above.
  • Wrong indentation in nested lists or in code inside a list. Indent by a consistent two or four spaces, and check the preview.
  • Underscores or asterisks inside words, such as snake_case_name, which some renderers may turn into italics. Wrap such text in backticks.
  • A pipe character inside a table cell. Escape it as \| or the cell is split in two.
  • Expecting a single line break to start a new line. Add two trailing spaces, a backslash or a blank line.

A simple structure for a README

  1. Project name and a one-sentence summary.
  2. How to install it.
  3. A minimal usage example in a fenced code block.
  4. A list of key features or options, perhaps as a table.
  5. How to contribute and how to report problems.
  6. The licence.

Frequently asked questions

What is the difference between Markdown, CommonMark and GitHub Flavored Markdown?
Markdown was originally described informally, which led to different interpretations. CommonMark is a precise specification of the core syntax. GitHub Flavored Markdown (GFM) builds on CommonMark and adds tables, task lists, strikethrough and automatic links.
Can I use HTML inside Markdown?
Many renderers allow it, but some remove or restrict HTML for security. If your content must work everywhere, prefer plain Markdown syntax.
How do I add a table of contents?
Standard Markdown has no table of contents syntax. Many platforms generate one automatically from headings, or you can write a list of links to heading anchors by hand.
Are Mermaid diagrams part of Markdown?
No, they are an extension. A renderer that supports Mermaid turns a code block labelled mermaid into a diagram, while one that does not will show the text as ordinary code.

Sources and further reading

Try it yourself: Markdown Previewer runs in your browser, free and with no sign-up.

More guides