Markdown Cheatsheet — Every Syntax Element with Examples
Markdown uses simple symbols for headings, bold, links, code, and tables. Here's a complete reference for CommonMark and GitHub Flavored Markdown syntax with working examples.
Markdown is a lightweight markup language that converts plain text to formatted HTML. It’s used in README files, documentation, GitHub comments, Jupyter notebooks, and static site generators. This is a complete reference for CommonMark (standard) and GitHub Flavored Markdown (GFM) syntax.
Use the Markdown Preview tool to write and preview Markdown in real time.
Headings
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
Alternate Heading 1
==================
Alternate Heading 2
------------------
Emphasis
**Bold text**
__Also bold__
*Italic text*
_Also italic_
***Bold and italic***
___Also bold and italic___
~~Strikethrough~~ (GFM)
Rendered:
- Bold text
- Italic text
- Bold and italic
Strikethrough
Lists
Unordered lists
- Item 1
- Item 2
- Nested item 2a
- Nested item 2b
- Item 3
* Also valid
+ Also valid
Ordered lists
1. First item
2. Second item
3. Third item
1. Nested item
2. Nested item
1. Numbers don't have to be in order
1. They all render correctly
1. As consecutive numbered items
Task lists (GFM)
- [x] Completed task
- [ ] Incomplete task
- [x] Another done item
Links
[Link text](https://example.com)
[Link with title](https://example.com "Hover text")
[Reference link][ref-id]
[ref-id]: https://example.com
Bare URL: <https://example.com>
Email: <user@example.com>
Images


![Reference image][img-ref]
[img-ref]: image.png "Title"
Code
Inline code
Use `backticks` for inline code.
Use `const x = 1` in your JavaScript.
Fenced code blocks
```javascript
function greet(name) {
return `Hello, ${name}!`;
}
```
```python
def greet(name):
return f"Hello, {name}!"
```
```
No language: plain code block
```
Code blocks support syntax highlighting in most Markdown renderers when you specify the language.
Blockquotes
> This is a blockquote.
> It can span multiple lines.
> First paragraph.
>
> Second paragraph — blank line needed.
> Nested blockquote:
> > This is inside the first quote.
Horizontal rules
---
***
___
All three create a horizontal rule <hr>.
Tables (GFM)
| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| Cell 1 | Cell 2 | Cell 3 |
| Cell 4 | Cell 5 | Cell 6 |
| Left | Center | Right |
|:---------|:--------:|---------:|
| Left | Center | Right |
Alignment:
:---— left align (default):---:— center align---:— right align
Footnotes (GFM / extended)
Here is a footnote reference[^1] in a paragraph.
[^1]: This is the footnote content.
Multiple paragraphs in footnote:
[^2]: First paragraph.
Second paragraph (4 spaces indent).
Escaping special characters
\* Not italic
\` Not inline code
\# Not a heading
\\ Literal backslash
\[ Not a link
Characters that may need escaping: \ * _ { } [ ] ( ) # + - . !
HTML in Markdown
CommonMark allows raw HTML:
<div class="alert">
Custom HTML block with <strong>bold</strong> text.
</div>
This is <span style="color: red">red text</span> inline.
Note: GitHub Flavored Markdown sanitizes HTML for security (most CSS and JavaScript removed).
Definition lists (extended Markdown)
Not part of CommonMark but supported by many parsers (kramdown, pandoc):
Term 1
: Definition 1
Term 2
: Definition 2a
: Definition 2b
Math (extended — KaTeX/MathJax)
Supported in Jupyter notebooks, some documentation tools, and GitHub (2022+):
Inline math: $E = mc^2$
Block math:
$$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$
Markdown in different contexts
GitHub: Uses GFM. Supports task lists, tables, auto-linking URLs, @mentions, #issue references.
Stack Overflow: Custom Markdown with limited HTML. No task lists or footnotes.
Jupyter Notebooks: Supports LaTeX math, HTML, and extended Markdown.
Docusaurus / GitBook: MDX (Markdown + JSX) — lets you embed React components.
VS Code: Full CommonMark + some GFM extensions in preview.
Jekyll/Hugo: CommonMark or Goldmark parsers. Front matter (YAML/TOML) in --- delimiters.
Markdown parsers
| Parser | Language | Spec | Notes |
|---|---|---|---|
| marked | JavaScript | GFM | Most popular JS parser |
| remark | JavaScript | CommonMark | AST-based, plugin ecosystem |
| markdown-it | JavaScript | CommonMark | Fast, extensible |
| Goldmark | Go | CommonMark | Used by Hugo |
| kramdown | Ruby | Extended | Used by Jekyll |
| pandoc | Haskell | Extended | Converts to any format |
Parsers differ in edge case handling. If your Markdown looks correct but renders wrong, check which parser is being used.
Related tools
- Markdown Preview — live Markdown editing and preview
- Markdown Editor Online — Markdown editor guide
- Markdown Syntax Guide — syntax deep dive
Related posts
- Markdown Code Blocks — Syntax Highlighting and Fenced Code — Markdown code blocks use triple backticks to display formatted code. Add a langu…
- Markdown Editor Online — Write and Preview Markdown Instantly — An online Markdown editor shows the rendered output as you type, so you don't ne…
- Markdown for Documentation — Structuring Technical Docs with Markdown — Markdown is the standard format for technical documentation. Here's how to struc…
- What Is Lorem Ipsum? The Real History and When to Stop Using It — Lorem Ipsum comes from a 45 BC Cicero text, not random Latin. Here's the actual …
- Markdown Syntax — Complete Guide with Live Examples — Markdown syntax covers headings, bold, italic, links, images, code blocks, table…
Related tool
Live Markdown preview with GitHub-flavored syntax. Tables, task lists, code blocks, strikethrough. Side-by-side editor and rendered output.
Written by Mian Ali Khalid. Part of the Dev Productivity pillar.