Markdown Cheat Sheet: Syntax for Headings, Lists and Code
A Markdown cheat sheet with the syntax for headings, bold, italic, lists, links, images, code blocks and blockquotes, plus GitHub extras like task lists.
Updated
Markdown is a plain-text syntax that converts to HTML: # starts a heading, **text** makes bold, *text* makes italic, - starts a list item and [text](url) creates a link. The tables below cover the syntax you will use most, followed by the GitHub Flavored Markdown extras.
What Markdown is
John Gruber published Markdown in 2004, with input from Aaron Swartz, as a way to write for the web in text that stays readable as text. The original description left some edge cases undefined, so parsers drifted apart. CommonMark, started in 2014, is a strict specification that most modern tools follow. GitHub Flavored Markdown (GFM) builds on CommonMark and adds a few features.
You will meet Markdown in README files, documentation sites, static site generators, note-taking apps, and comment boxes on GitHub, Reddit and Discord. Files normally end in .md.
Text formatting
| Element | Markdown | Notes |
|---|---|---|
| Bold | **bold text** | Two underscores on each side also work |
| Italic | *italic text* | One underscore on each side also works |
| Bold and italic | ***both*** | Three asterisks |
| Inline code | Wrap the text in single backticks | Shown in a monospace font, formatting inside is ignored |
| Link | [link text](https://example.com) | Add a title in quotes after the URL for a tooltip |
| Image |  | Same as a link with ! in front |
| Escape | \*not italic\* | A backslash makes the next symbol literal |
Headings
A heading is one to six # characters, a space, then the text. The number of # characters sets the level.
# Heading 1## Heading 2### Heading 3#### Heading 4##### Heading 5###### Heading 6
Always put a space after the # characters. Some older parsers accepted #Heading, but CommonMark does not. Use one level 1 heading per document and do not skip levels, since headings become the page outline used by screen readers and tables of contents.
Paragraphs and line breaks
- A blank line separates paragraphs.
- A single newline inside a paragraph is treated as a space, so you can wrap long lines in your editor without changing the output.
- For a hard line break, end the line with two or more spaces. CommonMark also accepts a backslash at the end of the line.
- Three or more hyphens, asterisks or underscores on a line of their own, such as
---, make a horizontal rule.
Lists
| List type | Markdown | Notes |
|---|---|---|
| Bulleted | - item | * and + work as bullets too |
| Numbered | 1. item | The numbers in the source do not have to be in order |
| Nested | Indent the child item under its parent | Two to four spaces, aligned with the parent's text |
A numbered list takes its starting number from the first item and counts up from there, so many writers number every item 1. and let the renderer do the counting. To put a second paragraph or a code block inside a list item, indent it to line up with the item's text.
Blockquotes
Start each line with > and a space:
> This is a quoted line.> It continues here.
Consecutive quoted lines form one blockquote. Quotes can contain other Markdown, including lists and nested quotes written as >>.
Code
Inline code uses single backticks around the text. For a block of code there are two forms:
- Fenced block. Put three backticks on a line of their own, then the code, then three backticks on another line. Add a language name such as
jsorpythonright after the opening backticks to request syntax highlighting where the renderer supports it. - Indented block. Indent every line by four spaces. This is the original syntax; fenced blocks are easier to read and are part of CommonMark.
Nothing inside a code block is interpreted as Markdown, so asterisks and # characters appear exactly as typed.
Links and images in more detail
- Inline link:
[GameParticles](https://gameparticles.com) - Link with a title:
[GameParticles](https://gameparticles.com "Free tools") - Automatic link:
<https://example.com>turns the URL itself into a link - Reference link: write
[link text][docs]in the paragraph and define[docs]: https://example.com/docson its own line anywhere in the document - Image:

Reference links keep long URLs out of your sentences and let you reuse one URL in several places. Markdown has no syntax for image size or alignment; where a renderer allows raw HTML you can use an img tag for that.
GitHub Flavored Markdown extras
These are not part of CommonMark, but they work on GitHub and in many editors and note apps.
| Feature | Markdown | Result |
|---|---|---|
| Strikethrough | ~~removed~~ | Text with a line through it |
| Task list, open | - [ ] write tests | An empty checkbox |
| Task list, done | - [x] write tests | A ticked checkbox |
| Autolink | https://example.com | Bare URLs become links without angle brackets |
| Table | Pipes between cells, hyphens under the header | A table with optional column alignment |
A table is written with pipes between cells and a row of hyphens under the header:
| Name | Role || --- | --- || Ada | Engineer |
Tables have enough rules of their own, including alignment, escaped pipes and line breaks in cells, to fill a separate guide: see Markdown table syntax. GitHub also supports footnotes written as [^1], which are a GitHub feature outside the GFM specification.
Common mistakes
- No blank line before a list or a heading. Some parsers need one to recognize the block.
- Missing space after
#,-or1. - Unescaped special characters. To show a literal asterisk, underscore or backtick, put a backslash in front, as in
\*. - Underscores inside words.
snake_case_namestays literal in CommonMark, but older parsers may italicize the middle. Put identifiers in inline code to be safe. - Assuming every extra works everywhere. Tables, task lists and strikethrough depend on the renderer.
Checking how your Markdown renders
The quickest way to learn the syntax is to type it and watch the output. The Markdown Preview shows an editor and the rendered result side by side and updates as you type. To get the HTML itself, the Markdown to HTML converter shows formatted HTML source with a copy button, plus a preview tab.
Both tools handle the core syntax on this page: headings from level 1 to 6, bold and italic written with asterisks, inline code, fenced code blocks, links, blockquotes, bulleted lists, horizontal rules and basic tables. They do not currently render numbered lists as list elements, images, underscore emphasis, nested lists, strikethrough or task lists, so check those features in the application where your document will be published.
More converters and formatters are in the text category.
Try it
Open the Markdown Preview, type a heading, a bulleted list and a fenced code block, and watch the rendered version appear beside it. When it looks right, paste the same text into the Markdown to HTML converter to copy the HTML.