X Xerobit

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.

Mian Ali Khalid · · 6 min read
Use the tool
Markdown Preview
Live Markdown preview with GitHub-flavored syntax. Tables, task lists, code blocks, strikethrough. Side-by-side editor and rendered output.
Open Markdown Preview →

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
[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

![Alt text](image.png)
![Alt text](image.png "Optional title")
![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

ParserLanguageSpecNotes
markedJavaScriptGFMMost popular JS parser
remarkJavaScriptCommonMarkAST-based, plugin ecosystem
markdown-itJavaScriptCommonMarkFast, extensible
GoldmarkGoCommonMarkUsed by Hugo
kramdownRubyExtendedUsed by Jekyll
pandocHaskellExtendedConverts to any format

Parsers differ in edge case handling. If your Markdown looks correct but renders wrong, check which parser is being used.


Related posts

Related tool

Markdown Preview

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.