Markdown Syntax Cheatsheet
A complete reference guide to Markdown syntax. Markdown is a lightweight markup language that lets you format plain text using simple symbols. It was created by John Gruber in 2004 and has since become the standard for writing documentation, README files, forum posts, and more. This guide covers the original Markdown specification plus widely-supported extensions.
Headings
Create headings by starting a line with one or more # symbols. The number of hashes determines the heading level (1 through 6).
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6You can also create level 1 and 2 headings by underlining text with = or - characters:
Heading 1
=========
Heading 2
---------Best practice: Always put a space between the # and the heading text, and leave a blank line before and after each heading for readability.
Text Formatting
Markdown supports several inline text formatting styles that you can combine freely.
| Style | Syntax | Result |
|---|---|---|
| Bold | **bold text** | bold text |
| Italic | *italic text* | italic text |
| Bold + Italic | ***bold italic*** | bold italic |
| Strikethrough | ~~deleted text~~ | |
| Inline code | `code` | code |
| Highlight | ==highlighted== | highlighted |
| Subscript | H~2~O | H2O |
| Superscript | X^2^ | X2 |
Paragraphs and Line Breaks
To create a new paragraph, separate text with a blank line. Single line breaks within a paragraph are typically joined into one continuous line. To force a line break without creating a new paragraph, end a line with two spaces or use a backslash (\).
This is the first paragraph.
This is the second paragraph.
This line has a forced break\
and continues on the next line.Links
Markdown supports several link formats for different use cases.
Inline Links
[Link text](https://example.com)
[Link with title](https://example.com "Hover title")Reference Links
Reference-style links separate the URL from the text, making documents cleaner when the same URL appears multiple times:
[Link text][ref-id]
[ref-id]: https://example.com "Optional title"Autolinks
Wrap a URL or email in angle brackets to create a clickable link automatically:
<https://example.com>
<[email protected]>Images
Image syntax is identical to links but prefixed with an exclamation mark. The text inside the brackets becomes the alt text for accessibility.


![Alt text][img-ref]
[img-ref]: image-url.png "Title"To make an image a clickable link, wrap the image syntax inside link syntax:
[](https://example.com)Lists
Unordered Lists
Create bullet lists with -, *, or + followed by a space:
- First item
- Second item
- Nested item
- Another nested item
- Third itemOrdered Lists
Use numbers followed by a period. The actual numbers don't matter — Markdown will number them sequentially:
1. First item
2. Second item
3. Third item
1. Nested ordered item
2. Another nested itemTask Lists
Create interactive checkboxes (supported on GitHub, GitLab, and most modern renderers):
- [x] Completed task
- [x] Another completed task
- [ ] Incomplete task
- [ ] Another incomplete taskBlockquotes
Prefix lines with > to create blockquotes. You can nest them and include other Markdown formatting inside:
> This is a blockquote.
>
> It can span multiple paragraphs.
> Nested blockquotes:
>> Second level
>>> Third levelCode
Inline Code
Wrap text in single backticks for inline code. Use double backticks if your code contains a backtick:
Use `console.log()` to debug.
Use ``code with a ` backtick`` inside.Fenced Code Blocks
Use triple backticks or triple tildes for multi-line code blocks. Add a language identifier for syntax highlighting:
```javascript
function greet(name) {
return `Hello, ${name}!`;
}
```
```python
def greet(name):
return f"Hello, {name}!"
```Common language identifiers: javascript, python, typescript, html, css, bash, json, sql, go, rust, java, c, cpp.
Indented Code Blocks
Indent lines by 4 spaces or 1 tab to create a code block (no syntax highlighting):
function example() {
return true;
}Tables
Create tables using pipes (|) and hyphens (-). Use colons for alignment:
| Left-aligned | Center-aligned | Right-aligned |
| :----------- | :------------: | ------------: |
| Cell 1 | Cell 2 | Cell 3 |
| Cell 4 | Cell 5 | Cell 6 |The outer pipes are optional, and columns don't need to be perfectly aligned in your source — but aligning them makes the source easier to read. You can use our Markdown Table Generator to create tables visually.
Horizontal Rules
Create a horizontal divider with three or more hyphens, asterisks, or underscores on their own line:
---
***
___Footnotes
Add footnotes to provide additional context without cluttering the main text:
Here is a sentence with a footnote.[^1]
[^1]: This is the footnote content.
You can also use multi-paragraph footnotes.[^note]
[^note]:
First paragraph of the footnote.
Second paragraph of the footnote.Definition Lists
Some Markdown processors support definition lists for glossary-style content:
Term 1
: Definition for term 1
Term 2
: First definition for term 2
: Second definition for term 2Escaping Characters
Use a backslash (\) to display literal characters that would otherwise be interpreted as Markdown formatting:
\* Not italic \*
\# Not a heading
\[Not a link\](url)
\`Not code\`Characters you can escape: \ ` * _ {} [] () # + - . ! |
HTML in Markdown
Most Markdown processors allow inline HTML for cases where Markdown syntax falls short:
This is a <sup>superscript</sup> example.
<details>
<summary>Click to expand</summary>
Hidden content here. You can use **Markdown** inside HTML blocks.
</details>However, be aware that HTML support varies by platform. GitHub, for example, sanitizes some HTML tags for security.
Extended Syntax Comparison
Not all Markdown features are universally supported. Here's what to expect across common platforms:
| Feature | CommonMark | GitHub (GFM) | MD Viewer |
|---|---|---|---|
| Tables | No | Yes | Yes |
| Task lists | No | Yes | Yes |
| Strikethrough | No | Yes | Yes |
| Footnotes | No | Yes | Yes |
| LaTeX math | No | Yes | Yes |
| Mermaid diagrams | No | Yes | Yes |
| Syntax highlighting | No | Yes | Yes |
| Autolinks | Yes | Yes | Yes |
| Highlight (==) | No | No | Yes |
Try it out — paste any Markdown into MD Viewer and see it rendered instantly with syntax highlighting, math, and diagrams.
Open MD Viewer