Skip to content

Markdown Cheat Sheet

Markdown syntax reference — headers, emphasis, lists, links, images, code blocks, tables, blockquotes, and GitHub-flavored extensions.

Every Markdown construct you actually use, with the source and the rendered output side-by-side.

Markdown is plain text with a few simple conventions for formatting. The tables below show the source on the left and how it renders on the right. The examples target CommonMark and GFM; chat applications and other renderers can use different syntax. [GFM] marks GitHub-flavored extensions that are not part of the original spec.

Headings

SourceRenders as
# Heading 1
Heading 1
## Heading 2
Heading 2
### Heading 3
Heading 3
#### Heading 4
Heading 4
##### Heading 5
Heading 5
###### Heading 6
Heading 6

Emphasis

SourceRenders as
*italic* italic
_italic_ italic
**bold** bold
__bold__ bold
***bold italic*** bold italic
~~strikethrough~~ [GFM] strikethrough
`inline code` inline code

Lists

SourceRenders as
- Item one - Item two - Nested item
  • Item one
  • Item two
    • Nested item
1. First 2. Second 3. Third
  1. First
  2. Second
  3. Third
- [x] Done - [ ] Todo [GFM]
  • ☑ Done
  • ☐ Todo

Code

SourceRenders as
`inline code` inline code
``` code block ```
code block
```js const x = 1 ``` [highlighting depends on renderer]
const x = 1
Indent 4 spaces for a code block
indented as code

Tables

Tables are a GitHub-flavored extension. Align with colons in the divider row.

SourceRenders as
| Col A | Col B | | --- | --- | | 1 | 2 | | 3 | 4 |
Col ACol B
12
34
| Left | Center | Right | | :--- | :---: | ---: | | a | b | c |
LeftCenterRight
abc

Quotes & Rules

SourceRenders as
> Quoted text
Quoted text
> Quote line one > Quote line two
Quote line one Quote line two
(one paragraph — put a line with just > between them to split it)
---
***

Escape Characters

Prefix special characters with a backslash to render them literally.

SourceRenders as
\*not italic\* *not italic*
\# not a heading # not a heading
\[not a link\] [not a link]
\\ \

Markdown is a lightweight markup language for text that converts to HTML. The cheat sheet above is a reference for the syntax; this companion explains what CommonMark specifies and what depends on extensions such as GitHub Flavored Markdown (GFM).

Core CommonMark

These examples target CommonMark. Older or specialized Markdown renderers may differ.

Headings

# Heading 1
## Heading 2
### Heading 3
###### Heading 6

Alternative syntax for H1 and H2:
Heading 1
=========

Heading 2
---------

The # form is more common. Number of # characters = heading level.

Emphasis

*italic*       _italic_
**bold**       __bold__
***both***     ___both___
~~strikethrough~~     ← GFM extension

Single * or _ for italic, double for bold, triple for both. The strikethrough form is a GFM extension; CommonMark doesn’t include it but most modern renderers do.

Lists

Unordered:
- Item 1
- Item 2
  - Nested item
* Also works with asterisks
+ Or plus signs

Ordered:
1. First
2. Second
3. Third

Align nested content with the parent item’s content column; the required indentation depends on its marker width. Numbered list numbers can be in any order — 1. 1. 1. renders as 1. 2. 3. because the renderer auto-numbers.

[link text](https://example.com)
[link with title](https://example.com "hover title")
<https://autolinked-bare-url.com>     ← autolinks
[reference style][1]

[1]: https://example.com

Reference-style links keep the URL away from the prose, which makes long links easier to read.

Images

![alt text](image.png)
![alt with title](image.png "hover")

Same as links but with a leading !. The alt text matters for accessibility — don’t skip it.

Code

Inline `code` with backticks.

```javascript
// Code block with language hint for syntax highlighting
const x = 42;
```

    Indented code block (four spaces at top level)

Triple-backtick fenced code blocks are the modern standard. The language hint after the opening fence enables syntax highlighting in renderers that support it.

Blockquotes

> This is a quote.
> > Nested quote.
> 
> Another paragraph in the same quote.

> at the start of each line.

Horizontal rule

---
***
___

Three or more -, *, or _ on a line by itself.

GitHub Flavored Markdown (GFM) extensions

Check whether your renderer enables these extensions.

Tables

| Header | Header |
|--------|--------|
| Cell   | Cell   |
| Cell   | Cell   |

Alignment via colons in the separator row:

| Left | Center | Right |
|:-----|:------:|------:|

Not in CommonMark. See CSV to Markdown table for generation.

Task lists

- [ ] Open task
- [x] Completed task
- [ ] Another open task

GFM renders these as task-list checkboxes. Interaction and support elsewhere depend on the host application.

Strikethrough

~~deprecated text~~

GFM extension.

Autolinked URLs

Any URL like https://example.com gets auto-linked.

GFM autolinks bare URLs in prose. CommonMark requires explicit <url> syntax.

Code fence languages

```bash
echo "hello"
```

The info string after a fence is part of CommonMark, not a GFM-only extension. Syntax highlighting depends on the renderer. The examples here use a longer outer fence to display literal triple backticks.

Less universal

These vary widely; check your target renderer.

Footnotes

Here is a footnote reference.[^1]

[^1]: This is the footnote text.

Supported by some Markdown parsers (Hugo, MultiMarkdown, Pandoc) but not all. GitHub added support in 2021.

Definition lists

Term
:   Definition

Supported by Pandoc, MultiMarkdown; not by CommonMark or vanilla GFM.

Math

Inline math: $E = mc^2$
Block math:
$$
\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
$$

Math is outside CommonMark and the core GFM specification. A host can add a math renderer; GitHub documents its supported math syntax separately.

Mermaid diagrams

```mermaid
graph TD
  A --> B
  B --> C
```

GitHub and some other renderers render Mermaid syntax to SVG diagrams. Not standard.

Frontmatter

---
title: My Post
date: 2026-04-30
---

YAML or TOML at the top of a file, used by static-site generators (Jekyll, Hugo, Astro). Not part of Markdown itself; the renderer/build tool extracts and uses it separately.

Common pitfalls

  • Identifiers. CommonMark does not turn intraword underscores in my_variable_name into emphasis. Backticks are still useful to mark it as code and preserve punctuation.
  • Asterisks in literal text. *important* becomes italic. Escape with backslash: \*important\*.
  • Bare angle brackets. <email@example.com> autolinks. To show literal angle brackets, escape or use &lt;/&gt;.
  • Blank lines and lists. Blank lines make the intended structure easier to read. CommonMark can start some lists directly after a paragraph, with restrictions; an ordered list interrupting a paragraph must start at 1.
  • Tabs vs spaces. CommonMark expands tabs to four-column tab stops for block structure. Spaces make nesting easier to inspect across editors.
  • Trailing two spaces for line break. Markdown’s “soft break” (single newline) is ignored in most renderers; for an explicit <br>, end the line with two spaces or use \ at end of line. The two-space convention is invisible in most editors and a common gotcha.

For converting Markdown to a preview, see markdown preview. For other reference docs, HTML entities, git commands.

Sources and scope

Checked September 27, 2026: CommonMark 0.31.2, GFM specification, and GitHub math support. Preview in the renderer that will publish your document.