Markdown Cheat Sheet: Complete Syntax Reference with Examples
Markdown is the universal writing format for developers — README files, documentation, GitHub issues, pull request descriptions, and technical blogs all use it. The syntax is minimal by design: a few punctuation conventions translate to clean HTML. This reference covers standard CommonMark syntax plus the GitHub Flavored Markdown (GFM) extensions that most platforms support.
Headings
# H1 — Page title (use once per document)
## H2 — Major section
### H3 — Subsection
#### H4 — Sub-subsection
##### H5
###### H6Always put a space between the # and the heading text. Leave a blank line before and after headings.
Emphasis
| Markdown | Output |
|---|---|
**bold** | bold |
*italic* or _italic_ | italic |
***bold italic*** | bold italic |
~~strikethrough~~ | |
`inline code` | inline code |
Lists
- Unordered item (use - or * or +)
- Second item
- Nested item (indent 2 spaces)
- Deeper nested
1. Ordered item
2. Second item
1. Nested ordered
3. Third itemFor consistent rendering, use - for unordered lists. Do not mix marker characters in the same list. Indent nested items by 2 spaces (CommonMark) or 4 spaces (some older parsers).
Task lists (GFM)
- [x] Completed task
- [ ] Incomplete task
- [ ] Another taskLinks and images
[Link text](https://example.com)
[Link with title](https://example.com "Tooltip on hover")


<!-- Reference-style links -->
[Link text][ref]
[ref]: https://example.com "Optional title"Blockquotes
> This is a blockquote.
> It can span multiple lines.
>
> Separate paragraphs with a blank quoted line.
>
> > Nested blockquote.Code blocks
```javascript
const greeting = "Hello, world!";
console.log(greeting);
```
```python
def greet(name):
return f"Hello, {name}!"
```
```sql
SELECT id, name FROM users WHERE active = true;
```Always specify the language identifier after the opening backticks — it enables syntax highlighting on GitHub, GitLab, and most documentation platforms.
Tables (GFM)
| Column 1 | Column 2 | Column 3 |
| -------- | :------: | -------: |
| Left | Center | Right |
| aligned | aligned | aligned |The colon in the separator row controls alignment: :---- = left (default), :----: = center, ----: = right. Pipes at the start and end are optional but recommended for readability.
Horizontal rules
---
***
___Three or more hyphens, asterisks, or underscores on their own line. Always surround with blank lines to avoid being parsed as an H2 underline.
Escaping
Backslash-escape any Markdown character to output it literally:
*not italic*
[not a link]
# not a headingHTML in Markdown
Most parsers allow raw HTML inline. Use it sparingly for things Markdown cannot express — centered content, custom attributes, or subscript/superscript:
H<sub>2</sub>O and E = mc<sup>2</sup>
<details>
<summary>Click to expand</summary>
Collapsed content here.
</details>Quick reference
| Element | Syntax |
|---|---|
| Heading | # H1 ## H2 ### H3 |
| Bold | **text** |
| Italic | *text* |
| Inline code | `code` |
| Code block | ```lang … ``` |
| Link | [text](url) |
| Image |  |
| Blockquote | > text |
| Unordered list | - item |
| Ordered list | 1. item |
| Horizontal rule | --- |
| Table (GFM) | | col | col | |
| Task list (GFM) | - [x] done - [ ] todo |
| Strikethrough (GFM) | ~~text~~ |
Try it yourself
Use the free browser-based Markdown Preview on DevBench — no signup, runs entirely in your browser.
Open Markdown Preview