← All cheat sheets

Languages

Markdown Cheat Sheet — Syntax Reference (with GFM)

Markdown syntax at a glance, including the GitHub Flavored Markdown (GFM) extensions used in READMEs and issues.

Put it into practice with the matching tool.

Preview Markdown →

Advertisement

Headings & emphasis

# Heading 1Top-level heading (up to ###### for level 6)
**bold**Bold text
*italic*Italic text
***bold italic***Bold and italic
~~strikethrough~~Strikethrough (GFM)

Lists

- itemUnordered list item
1. itemOrdered list item
- nestedNested item (indent by two spaces)
- [ ] todoUnchecked task list item (GFM)
- [x] doneChecked task list item (GFM)

Links & images

[text](https://example.com)Inline link
[text](url "title")Link with hover title
![alt](image.png)Image
<https://example.com>Autolink a bare URL

Code

`inline code`Inline code span
```jsStart a fenced code block with syntax highlighting
```Close a fenced code block
four spacesIndented code block (legacy style)

Tables (GFM)

| A | B |Header row
| --- | --- |Divider row (required)
| :--- |Left-align the column
| :---: |Center the column
| ---: |Right-align the column

Other blocks

> quoteBlockquote
---Horizontal rule
line ending with two spacesForce a line break
\*escaped\*Escape a Markdown character with a backslash

Markdown in practice

Writing Markdown that renders everywhere

Leave a blank line before and after headings, lists, code blocks, block quotes and tables; many renderers require it and the source is easier to read. Use # headings rather than underlined ones, - for bullets, and fenced code blocks with a language name, such as three backticks followed by js, for syntax highlighting. These choices are supported by CommonMark, GitHub Flavored Markdown and nearly every tool built on them.

Line breaks and paragraphs

A single line break inside a paragraph is normally rendered as a space, so wrapping lines in your editor does not affect the output. To force a line break, end the line with two spaces or a backslash — or, in many tools, use an HTML <br>. GitHub renders single line breaks literally in issues and comments but not in Markdown files, which is the source of many "it looked right in the preview" surprises.

Nested lists

In CommonMark, a nested item must be indented to line up with the text of its parent item, not by a fixed number of spaces. After - that means two spaces; after 1. it means three. Mismatched indentation is the most common reason nested lists flatten or turn into code blocks. To put a paragraph or code block inside a list item, indent it to the same level.

Links, images and accessibility

Give links descriptive text — "read the installation guide" rather than "click here" — because screen readers often list links out of context. Always fill in image alt text: ![Architecture diagram showing the API and database](diagram.png). Reference-style links, [guide][1] with [1]: https://... at the bottom, keep long URLs out of paragraphs and make the source easier to edit.

Escaping and special characters

Characters such as *, _, #, [ and backticks have meaning in Markdown. Escape them with a backslash when you want them literally: \*not italic\*. Inside inline code and code blocks, nothing needs escaping, which makes code spans the easiest way to show symbols. To show a backtick inside inline code, wrap the span in double backticks.

Related guides

More cheat sheets