# Markdown cheat sheet

> Markdown formats plain text with a few symbols: # for headings, ** for bold, - for lists, [text](url) for links, and backticks for code. This reference uses GitHub-flavored Markdown; math and Mermaid render in Markdown Lens and on GitHub.

Source: https://markdownlens.ayushdev.com/markdown-cheatsheet · Updated 2026-11-12 · Markdown Lens, free and open source: https://github.com/ayushhagarwal/markdown-lens

## Quick reference

| Element | Markdown syntax |
| --- | --- |
| Heading | `# H1  ## H2  ### H3` |
| Bold | `**bold text**` |
| Italic | `*italic text*` |
| Strikethrough | `~~deleted~~` |
| Link | `[title](https://example.com)` |
| Image | `![alt text](image.png)` |
| Inline code | ``code`` |
| Code block | ````js … ```` |
| Blockquote | `> quoted text` |
| Unordered list | `- item` |
| Ordered list | `1. item` |
| Task list | `- [ ] to do  - [x] done` |
| Table | `\| A \| B \|  then  \| --- \| --- \|` |
| Horizontal rule | `---` |
| Footnote | `text[^1]  [^1]: note` |
| Inline math | `$E = mc^2$` |
| Block math | `$$ … $$` |
| Escape a character | `\*not italic\*` |

## Headings, emphasis, and paragraphs

Start with the building blocks for readable Markdown documents. Leave a blank line between paragraphs.

### Headings

```markdown
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
```

### Emphasis

```markdown
**Bold text**

*Italic text*

***Bold and italic***

~~Strikethrough~~
```

### Blockquotes

```markdown
> Markdown keeps plain text readable.
>
> > Nest a quote with a second marker.
```

### Line breaks and rules

```markdown
First line\
Second line, same paragraph

---

A new section after a horizontal rule.
```

## Links and images

Square brackets hold the visible text; parentheses hold the URL. Images use the same pattern with a leading exclamation mark.

### Inline, reference, and auto links

```markdown
[Markdown Lens](https://markdownlens.ayushdev.com)

Read the [spec][gfm].

https://github.com is linked automatically.

[gfm]: https://github.github.com/gfm/
```

### Images

```markdown
![Markdown Lens icon](https://markdownlens.ayushdev.com/icon-192.png)

![Alt text describes the image](image.png "Optional title")
```

## Lists and task lists

Indent by two or more spaces to nest. Square brackets after a list marker create a checklist.

### Ordered and unordered lists

```markdown
- First item
- Second item
  - Nested item

1. Plan
2. Write
3. Review
```

### Task lists

```markdown
- [x] Draft the README
- [ ] Add examples
- [ ] Request review
```

## Tables

Separate the header with dashes and columns with vertical bars. Colons in the divider row set alignment.

### Table with column alignment

```markdown
| Left | Center | Right |
| :--- | :---: | ---: |
| Tables | Ready | 1 |
| Mermaid | Ready | 2 |
| Math | Ready | 3 |
```

## Code

Use single backticks for inline code and triple backticks for fenced blocks. Add a language name for syntax highlighting.

### Inline code

```markdown
Run `npm run dev` to start the app.
```

### Fenced code block

````markdown
```ts
const greeting = "Hello, Markdown!";
console.log(greeting);
```
````

## Footnotes and escaping

Footnotes collect references at the end of the document. A backslash prints a Markdown symbol literally.

### Footnotes

```markdown
Markdown was created in 2004.[^1]

[^1]: By John Gruber, with Aaron Swartz.
```

### Escaping characters

```markdown
\*Not italic\* and \# not a heading.

Use \\ for a literal backslash.
```

## Math and LaTeX

Markdown Lens renders KaTeX-compatible math. Use single dollar signs inline and double dollar signs for display equations.

### Inline and block math

```markdown
Inline: $E = mc^2$

Block:
$$
\int_0^1 x^2\,dx = \frac{1}{3}
$$
```

### Fractions, sums, and Greek letters

```markdown
$$
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
$$

$\alpha + \beta \le \sqrt{x_1^2 + x_2^2}$
```

### Matrices

```markdown
$$
A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}
$$
```

### Aligned equations

```markdown
$$
\begin{aligned}
f(x) &= (x + 1)^2 \\
     &= x^2 + 2x + 1
\end{aligned}
$$
```

## Mermaid diagrams

A fenced block with the mermaid language becomes a diagram in Markdown Lens and on GitHub.

### Flowchart

````markdown
```mermaid
flowchart LR
  A[Write] --> B[Preview]
  B --> C[Publish]
```
````

### Sequence diagram

````markdown
```mermaid
sequenceDiagram
  Writer->>Editor: Type Markdown
  Editor-->>Writer: Live preview
```
````

## Frequently asked questions

### What is a Markdown cheat sheet?

A Markdown cheat sheet is a one-page reference of Markdown syntax: the characters you type for headings, emphasis, lists, links, images, code, and tables. This page shows each pattern next to its rendered GitHub-style output so you can copy what you need.

### Which Markdown flavor does this cheat sheet use?

GitHub-flavored Markdown (GFM). It covers the CommonMark basics plus GFM tables, task lists, strikethrough, autolinks, and footnotes. Math and Mermaid examples work in Markdown Lens and on GitHub, but not in every Markdown renderer.

### How do I make a line break in Markdown?

End the line with a backslash or two trailing spaces, then continue on the next line. A blank line between lines starts a new paragraph instead.

### How do I align columns in a Markdown table?

Add colons to the divider row: :--- aligns left, :---: centers, and ---: aligns right.

### How do I write math or LaTeX in Markdown?

Wrap inline math in single dollar signs, like $a^2 + b^2 = c^2$, and put block equations between lines containing only $$. Markdown Lens renders both with KaTeX, which supports most common LaTeX math commands.

### How do I show a literal asterisk, underscore, or pound sign?

Put a backslash in front of it, for example \* or \#. Markdown then prints the character instead of treating it as formatting.
