Markdown is the most popular lightweight markup language used by developers, writers, and content creators worldwide. Created by John Gruber, this ultimate markdown cheatsheet provides complete syntax examples for text formatting, code blocks, tables, links, images, and advanced features. Whether you’re writing documentation, README files, or blog posts, this comprehensive guide covers everything you need to master markdown syntax.
Table of Contents
Text Formatting
Emphasis
Bold text
1
| **Bold text** or __Bold text__
|
Italic text
1
| *Italic text* or _Italic text_
|
Bold and italic
1
| ***Bold and italic*** or **_Bold and italic_**
|
Strikethrough
Superscript and Subscript
Einstein’s equation: E=mc2 (superscript)
Water molecule: H2O (subscript)
Escape Characters
Use backslash to escape special characters: *literal asterisks*
ATX Style (Recommended)
1
2
3
4
5
6
| # H1 Header
## H2 Header
### H3 Header
#### H4 Header
##### H5 Header
###### H6 Header
|
Setext Style (H1 and H2 only)
1
2
3
4
5
| Header 1
========
Header 2
--------
|
Note: Setext style only supports H1 (=) and H2 (-) headers. Use ATX style for H3-H6.
Lists
Unordered Lists
- Item 1
- Item 2
- Nested item
- Another nested item
- Item 3
1
2
3
4
5
| * Item 1
* Item 2
* Nested item
* Another nested item
* Item 3
|
Ordered Lists
- First item
- Second item
- Nested item
- Another nested item
- Third item
1
2
3
4
5
| 1. First item
2. Second item
1. Nested item
2. Another nested item
3. Third item
|
Task Lists
- Completed task
- Incomplete task
- Another completed task
1
2
3
| - [x] Completed task
- [ ] Incomplete task
- [x] Another completed task
|
Links
Inline Links
This is a Google link.
1
| [Google](https://www.google.com "Google Homepage")
|
Reference Links
This is a reference link and another reference link.
1
2
3
4
5
| [reference link][1]
[reference link][google]
[1]: https://www.google.com "Google"
[google]: https://www.google.com
|
Automatic Links
https://www.google.com
Images
Inline Images
1
| 
|
Reference Images
1
2
3
| ![HTML5 Logo][html5-logo]
[html5-logo]: https://www.w3.org/html/logo/badge/html5-badge-h-solo.png "HTML5 Logo"
|
Code
Inline Code
Use backticks
for inline code.
1
| Use `backticks` for inline code.
|
Code Blocks
1
2
3
| ```
Plain code block
```
|
Syntax Highlighting
1
2
3
| function hello() {
console.log("Hello World!");
}
|
1
2
3
4
5
| ```javascript
function hello() {
console.log("Hello World!");
}
```
|
Indented Code Blocks
1
2
| This is an indented code block
using 4 spaces or 1 tab
|
1
2
| This is an indented code block
using 4 spaces or 1 tab
|
Line Numbers in Code Blocks
Note: Line numbers syntax varies by platform. Some use {linenos=true}
, others use different attributes.
1
2
3
4
| function hello() {
console.log("Hello World!");
return true;
}
|
1
2
3
4
5
6
| ```javascript {.line-numbers}
function hello() {
console.log("Hello World!");
return true;
}
```
|
Tables
Left Aligned | Center Aligned | Right Aligned |
---|
Left | Center | Right |
Text | Text | Text |
1
2
3
4
| | Left Aligned | Center Aligned | Right Aligned |
|:-------------|:--------------:|--------------:|
| Left | Center | Right |
| Text | Text | Text |
|
Simple Table
Column 1 | Column 2 | Column 3 |
---|
Data 1 | Data 2 | Data 3 |
Data 4 | Data 5 | Data 6 |
1
2
3
4
| Column 1 | Column 2 | Column 3
---------|----------|----------
Data 1 | Data 2 | Data 3
Data 4 | Data 5 | Data 6
|
Blockquotes
This is a blockquote.
It can span multiple lines.
Nested blockquotes are also possible.
1
2
3
4
5
| > This is a blockquote.
>
> It can span multiple lines.
>
> > Nested blockquotes are also possible.
|
Horizontal Rules
Three or more dashes, asterisks, or underscores:
Line Breaks
End a line with two or more spaces for a line break.
First line Second line
1
2
| First line
Second line
|
HTML Elements
Definition Lists
- Term 1
- Definition 1
- Term 2
- Definition 2
1
2
3
4
5
6
| <dl>
<dt>Term 1</dt>
<dd>Definition 1</dd>
<dt>Term 2</dt>
<dd>Definition 2</dd>
</dl>
|
Preformatted Text
Preformatted text
preserves spaces
and line breaks
1
2
3
4
5
| <pre>
Preformatted text
preserves spaces
and line breaks
</pre>
|
YouTube Videos (HTML)
1
2
3
| <a href="https://www.youtube.com/watch?v=mCG1tvUuCTo" target="_blank" rel="noopener">
<img src="https://img.youtube.com/vi/mCG1tvUuCTo/0.jpg" alt="Video Thumbnail" width="240" height="180">
</a>
|
YouTube Videos (Markdown)

1
| [](https://www.youtube.com/watch?v=mCG1tvUuCTo)
|
Special Features
Emoji
😄 ❤️ 👍 🐙 (Unicode) or :smile: :heart: :thumbsup: :octocat: (shortcodes)
1
2
| 😄 ❤️ 👍 🐙 (Unicode)
:smile: :heart: :thumbsup: :octocat: (shortcodes - requires jemoji plugin)
|
Emoji Cheatsheet
Highlighting
Highlighted text
1
| <mark>Highlighted text</mark>
|
Keyboard Keys
Press Ctrl + C to copy.
1
| Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy.
|
Math Expressions
Inline Math
This is inline math: \(E = mc^2\) and here’s another example with the quadratic formula \(x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\).
Block Math
\[\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}\]
1
2
3
| $$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$
|
Equation Numbering
\[\begin{equation} E = mc^2 \label{eq:einstein} \end{equation}\]
You can reference the equation above using \eqref{eq:einstein}.
1
2
3
4
5
6
7
| $$
\begin{equation}
E = mc^2 \label{eq:einstein}
\end{equation}
$$
Reference with \eqref{eq:einstein}
|
Math in Lists
- First equation: $$ a^2 + b^2 = c^2 $$
- Second equation: $$ \sum_{i=1}^{n} i = \frac{n(n+1)}{2} $$
- Third equation: $$ \lim_{x \to \infty} \frac{1}{x} = 0 $$
1
2
3
| 1. \$$ a^2 + b^2 = c^2 $$
2. \$$ \sum_{i=1}^{n} i = \frac{n(n+1)}{2} $$
3. \$$ \lim_{x \to \infty} \frac{1}{x} = 0 $$
|
Note: This site uses MathJax for rendering mathematical expressions. The Chirpy theme requires math: true
in the front matter and specific syntax rules: use $$ math $$
for inline math (no blank lines), $$ math $$
with blank lines for block math, and escape the first $
in lists with \$$
.
This text has a footnote.
1
2
3
| This text has a footnote[^1].
[^1]: This is the footnote content.
|
1
| <!-- This is a comment that won't be visible -->
|
Collapsible Sections
Click to expand
This content is hidden by default and can be expanded by clicking the summary. - Item 1 - Item 2 - Item 3 Code example:function example() {
console.log("Hello from collapsible section!");
}
1
2
3
4
5
6
7
8
9
10
11
12
13
| <details>
<summary>Click to expand</summary>
This content is hidden by default.
Code example:
<pre><code>function example() {
console.log("Hello from collapsible section!");
}
</code></pre>
</details>
|
Anchor Links
Link to custom header
1
2
| ### Custom ID Headers {#custom-header}
[Link to custom header](#custom-header)
|
Popular Markdown Editors
Choose the right Markdown editor for your workflow:
Online Editors
- StackEdit - Full-featured online editor with live preview, export to HTML/PDF, and cloud sync
- Dillinger - Clean web-based editor with export to HTML, styled HTML, PDF, and Markdown
- HackMD - Collaborative editor with real-time sync, presentation mode, and team features
Desktop Applications
- Typora - WYSIWYG editor with seamless live preview and export capabilities
- Obsidian - Knowledge management with Markdown support and graph visualization
IDE Extensions
- Vim Markdown - Vim plugin for Markdown syntax highlighting and folding
Markdown Flavors
Different platforms use variations of Markdown with additional features:
Standardized specification for consistent Markdown parsing across platforms. Visit the CommonMark spec for complete documentation.
Extends CommonMark with:
- Tables
- Task lists
- Strikethrough
- Autolinks
- Syntax highlighting in code blocks
Extended Syntax
Many processors support additional features:
- Footnotes
- Definition lists
- Table alignment
- Abbreviations
- Math expressions (LaTeX)
Note: Always check which Markdown flavor your target platform supports.
Best Practices
- Use consistent formatting throughout your document
- Add blank lines around headers and sections for readability
- Use descriptive alt text for images
- Include titles for links when helpful
- Test your markdown in your target renderer
- Use reference links for repeated URLs
- Indent nested lists properly with 2-4 spaces
- Use semantic headers (H1 for title, H2 for main sections)
- Keep line length reasonable (80-120 characters)
- Preview before publishing to catch formatting issues
Conclusion
This comprehensive markdown cheatsheet covers all essential syntax from basic text formatting to advanced features like math expressions and collapsible sections. Bookmark this reference for quick lookup while writing documentation, README files, or blog posts. Remember to test your markdown in your target environment since different renderers may have slight variations in support.
For more comprehensive guides and tutorials, visit The Markdown Guide - the definitive resource for learning Markdown.