Blog

The most complete markdown cheatsheet online

The most complete markdown cheatsheet online. Every syntax element with examples, rendered output, platform compatibility, common mistakes, and expert tips. Bookmark it.

Benjamin McBrayer // Published: April 21, 202616 min read

Also in

Markdown is a simple way to format text using symbols like hashtags, asterisks, and brackets. It is useful for writers, bloggers, developers, students, and anyone who creates content online, because it makes formatting fast, clean, and easy to reuse across different platforms. This Markdown cheatsheet will show you the most common rules so you can write and publish in Markdown from now on.

What Is Markdown?

Markdown is a lightweight markup language that allows you to use plain-text symbols to format documents. When you type **bold** you get bold. When you type # Heading it becomes a heading. When you use Markdown it converts to HTML. It works on virtually every platform and it has become the default language for formatting on thousands of tools, platforms, and websites including GitHub, Reddit, Discord, Notion, Slack, and Obsidian.


Why Markdown Is Important

John Gruber created Markdown in 2004 with the goal of letting people write and format documents using plain text without looking at a mess of tags. Today, Markdown has grown into a language that is used by virtually every developer and builder, as well as content writers and others.

The Benefits of Markdown

Markdown is so popular because it solves many problems that were an issue with earlier formats.

  • Markdown works everywhere and always will: You can open a .md file in any text editor and on any operating system, and you will be able to open it 50 years from now.
  • You can read Markdown without rendering it: Unlike RTF or HTML, Markdown is a format that is legible in its raw form, not only after rendering it.
  • Markdown is fast to work with: Experienced writers can format text as they type it and work faster.
  • Markdown is universal: As mentioned before, many platforms use Markdown natively.

Nowadays, Markdown is important to know for anyone building something with AI tools, because LLMs output Markdown by default.


Basic Markdown Syntax

These elements come from John Gruber's original 2004 specification. Every markdown parser supports them, with minor implementation differences noted below.

Quick Reference Table

Element Markdown Syntax
Markdown Heading # H1 ## H2 ### H3
Markdown Bold **bold** or __bold__
Markdown Italic *italic* or _italic_
Markdown Bold + Italic ***bold italic***
Markdown Blockquote > quoted text
Markdown Ordered List 1. Item
Markdown Unordered List - Item or * Item or + Item
Markdown Inline Code `code`
Markdown Code Block Indent 4 spaces, or use fenced blocks
Markdown Horizontal Rule --- or *** or ___
Markdown Link [text](https://example.com)
Markdown Image ![alt text](image.jpg)
Markdown Line Break End a line with two trailing spaces
Markdown Escape Character \*literal asterisk\*

Markdown Headings

Use 1–6 pound signs (#) followed by a space. The number of signs matches the HTML heading level.

# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6

Alternate syntax (Setext style) works for H1 and H2 only:

Heading 1
=========

Heading 2
---------

Best practices:

  • Always put a space between # and the heading text. #Heading works in some parsers but breaks in others.
  • Use only one H1 per document (usually the page title).
  • Don't skip heading levels. Go H1 → H2 → H3, not H1 → H3.
  • Add blank lines before and after headings for maximum compatibility.

Markdown Bold, Italic, and Emphasis

**This is bold** and __this is also bold__
*This is italic* and _this is also italic_
***Bold and italic*** combined

Renders as:

This is bold and this is also bold This is italic and this is also italic Bold and italic combined

Gotcha: Some parsers don't handle underscores in the middle of a word. For maximum compatibility, use asterisks for mid-word emphasis: un**believ**able, not un__believ__able.

Markdown Blockquotes

Start any line with > to create a markdown blockquote.

> This is a single-line blockquote.

> This is a blockquote
> that spans multiple lines.

> Blockquotes can be nested.
>
> > Like this.
>
> And they can contain **other markdown** elements.

Markdown blockquotes work well for emphasizing quotes, callouts, and reply-style formatting in emails.

Markdown Lists

Unordered lists accept -, *, or + interchangeably. Pick one style and stick with it for consistency.

- First item
- Second item
- Third item
  - Nested item (indent two or four spaces)
  - Another nested item
- Fourth item

Ordered lists use numbers followed by a period:

1. First item
2. Second item
3. Third item

Useful trick: The numbers don't have to be correct. Markdown renumbers automatically:

1. First
1. Second
1. Third

…renders identically to 1, 2, 3. This means you can reorder items without renumbering.

Nesting ordered and unordered markdown lists:

1. First step
2. Second step
   - Sub-bullet
   - Another sub-bullet
3. Third step
   1. Sub-step
   2. Another sub-step

List items with multiple paragraphs: Indent the continuation by the same number of spaces (usually 4, or one tab):

1. First item

    This paragraph belongs to the first item.
    Notice the blank line above and the indent.

2. Second item

Markdown Links

Inline links are the most common style:

[Visit Google](https://www.google.com)
[With hover title](https://www.google.com "Google's homepage")

Reference-style markdown links are useful when the same URL appears multiple times or when you want to keep prose clean:

I love [Obsidian][1] and [VS Code][vscode] for markdown.

[1]: https://obsidian.md
[vscode]: https://code.visualstudio.com

Automatic URLs. Wrap a bare URL in angle brackets:

<https://example.com>
<hello@example.com>

Relative links. Link to files in the same repository or folder:

[Read the license](./LICENSE.md)
[Parent directory file](../README.md)

Markdown anchor links. Jump to a heading on the same page. Most parsers auto-generate IDs from heading text (lowercase, spaces to hyphens):

Jump to [the installation section](#installation).

## Installation

Markdown Images

Markdown image syntax is the link syntax with a leading exclamation mark:

![Descriptive alt text](/path/to/image.jpg)
![Alt text](/path/to/image.jpg "Optional hover title")

Reference-style markdown images work the same way as reference links:

![Company logo][logo]

[logo]: /images/logo.png "Our logo"

Making a markdown image a link:

[![Alt text](image.jpg)](https://example.com)

Sizing images. Pure markdown has no syntax for this. Use inline HTML as a fallback:

<img src="image.jpg" alt="Alt text" width="400">

Accessibility note: Always write meaningful alt text. Screen readers depend on it, and search engines use it to understand image content. ![](logo.png) is bad; ![Company logo, blue circle with a white M](logo.png) is good.

Markdown Code

Markdown inline code wraps in single backticks:

Install with `npm install markdown-it`.

Markdown code blocks. Indent every line by four spaces (or one tab):

    function hello() {
      console.log("Hello, world!");
    }

In practice, almost everyone uses fenced code blocks instead (covered in the extended syntax section below) because they support syntax highlighting.

Escaping backticks inside inline code. Use more backticks on the outside:

To show a backtick, use `` `backtick` `` like this.

Markdown Horizontal Rules

Three or more hyphens, asterisks, or underscores on their own line:

---
***
___

All three render identically. Put blank lines before and after for compatibility.

Markdown Line Breaks

This is one of markdown's most confusing features. There are three different behaviors:

Paragraph break. Leave a blank line between text:

This is paragraph one.

This is paragraph two.

Hard line break (same paragraph). End a line with two trailing spaces:

This line ends with two spaces.␣␣
This line is a break within the same paragraph.

HTML fallback. Use <br> when trailing spaces feel too fragile:

This line has an HTML break.<br>
This is the next line.

Why trailing spaces are controversial: They're invisible. Most editors strip them on save. GitHub Flavored Markdown (GFM) solves this by treating any single newline as a line break within a paragraph, but standard CommonMark requires the trailing spaces.

Markdown Escape Characters

To display a character that markdown would normally interpret as formatting, precede it with a backslash:

\*This shows literal asterisks\*
\# This shows a literal hash sign
\[not a link\]

Escapable characters: \ ` * _ {} [] () # + - . ! |


Extended Markdown Syntax

These elements are not in Gruber's original specification, but most widely-used markdown processors support them, including GitHub, GitLab, Reddit, Stack Overflow, Obsidian, Notion, and Discord. Compatibility varies, so check the matrix below before relying on any of them.

Quick Reference Table

Element Markdown Syntax
Markdown Table | Header | Header | + | --- | --- |
Markdown Fenced Code Block ```language ... ```
Markdown Syntax Highlight Language name after opening fence
Markdown Footnote Here's a note.[^1] ... [^1]: Note text.
Markdown Heading ID ### My Heading {#custom-id}
Markdown Definition List term newline : definition
Markdown Strikethrough ~~deleted text~~
Markdown Task List - [x] Done - [ ] Todo
Markdown Emoji Shortcode :joy: :rocket:
Markdown Highlight ==highlighted==
Markdown Subscript H~2~O
Markdown Superscript E = mc^2^
Markdown Automatic URL <https://example.com>
GitHub Markdown Alerts > [!NOTE] > [!WARNING] > [!TIP]

Markdown Tables

Use pipes (|) for columns and a row of hyphens for the header separator.

| Name     | Role       | Location      |
| -------- | ---------- | ------------- |
| Alice    | Developer  | Berlin        |
| Bob      | Designer   | Montreal      |
| Carol    | Writer     | Sydney        |

Column alignment. Add colons to the separator row:

| Left-aligned | Centered     | Right-aligned |
| :----------- | :----------: | ------------: |
| apples       | bananas      |          $100 |
| cherries     | dates        |           $12 |

Tips that most guides miss:

  • You don't need to align the pipes in your source. The renderer handles spacing.
  • The outer pipes are optional, but adding them helps with readability and editor plugins.
  • You can use basic markdown inside cells (**bold**, *italic*, `code`, links).
  • You cannot use block elements (headings, blockquotes, lists) inside cells.
  • For multi-line content inside a cell, use <br> instead of a line break.
  • To display a literal pipe character inside a cell, use the HTML entity &#124;.

Markdown Fenced Code Blocks

Three backticks (or tildes) open and close a block. Add a language identifier after the opening fence for syntax highlighting:

```python
def greet(name):
    return f"Hello, {name}!"

print(greet("world"))
```

Common language identifiers: python, javascript, typescript, bash, shell, sql, json, yaml, html, css, rust, go, java, c, cpp, csharp, php, ruby, swift, kotlin, dart, r, scala, diff.

Showing code changes with diff:

```diff
- const old = "remove this";
+ const new = "add this";
```

Escaping triple backticks. Wrap the block in four backticks:

````
This block contains ```triple backticks``` inside.
````

Markdown Footnotes

Markdown footnotes are perfect for citations, asides, and explanatory notes without cluttering your prose.

Here is a statement that needs a source.[^1]

Here is another claim.[^detailed-note]

[^1]: This is a short footnote.
[^detailed-note]: Named footnotes still render as numbers, but they're
    easier to track in the source. They can span multiple lines if you
    indent the continuation.

Markdown Heading IDs

Some parsers let you assign custom IDs to headings for precise anchor linking:

### My Great Heading {#custom-heading-id}

Jump to [my heading](#custom-heading-id).

GitHub and many others auto-generate IDs from heading text, so you usually don't need this.

Markdown Definition Lists

Markdown
: A lightweight markup language for formatting plain text.

HTML
: The standard markup language for web pages.

CSS
: The language used to style HTML documents.

Support is spotty. It works in Pandoc, PHP Markdown Extra, and a few others, but not in standard GFM.

Markdown Strikethrough

Wrap text in two tildes to cross it out:

~~This text is struck through.~~

Renders as: This text is struck through.

Works in GFM, Reddit, Discord, Slack, and most widely-used processors. Not in standard CommonMark.

Markdown Task Lists

Interactive checkboxes, commonly used in GitHub issues, pull requests, and project boards:

- [x] Write the first draft
- [x] Edit for clarity
- [ ] Publish the article
- [ ] Promote on social media
  - [ ] Twitter
  - [ ] LinkedIn
  - [ ] Hacker News

On GitHub, these render as clickable checkboxes you can toggle directly in the UI.

Markdown Emoji

Most platforms support emoji shortcodes:

Ship it :rocket: and celebrate :tada::champagne:

You can also paste actual emoji characters directly. They render fine in any markdown file since they're just Unicode. 🚀🎉

Markdown Highlight, Subscript, Superscript

I need to ==highlight== this important idea.
Water is H~2~O.
Einstein's famous equation: E = mc^2^.

Support is limited. Works in Obsidian, MultiMarkdown, and some extended parsers, but not GFM.

Markdown Automatic URL Linking

Wrap a URL in angle brackets to create an automatic link:

<https://example.com>
<contact@example.com>

In GitHub Flavored Markdown, any bare URL is automatically converted. You don't even need the brackets.


Platform Compatibility Matrix

Use this table to check which syntax elements work on the platforms you use. "Yes" means full support, "No" means no support, and "Partial" means the feature works with limitations or uses a non-standard syntax.

Feature GFM GitLab Reddit Discord Slack Notion Obsidian Stack Overflow
Headings Yes Yes Yes No No Yes Yes Yes
Bold / Italic Yes Yes Yes Yes Partial* Yes Yes Yes
Strikethrough Yes Yes Yes Yes Yes Yes Yes Yes
Blockquote Yes Yes Yes Yes Yes Yes Yes Yes
Lists Yes Yes Yes Yes Yes Yes Yes Yes
Inline Code Yes Yes Yes Yes Yes Yes Yes Yes
Fenced Code Yes Yes Yes Yes Yes Yes Yes Yes
Syntax Highlight Yes Yes Partial Partial No Yes Yes Yes
Links Yes Yes Yes Yes Partial** Yes Yes Yes
Images Yes Yes Partial Partial Partial Yes Yes Yes
Tables Yes Yes Yes No No Yes Yes Yes
Task Lists Yes Yes No No No Yes Yes No
Footnotes Yes Yes No No No No Yes No
Emoji Shortcodes Yes Yes No Yes Yes No Partial No
Math (LaTeX) Yes Yes No No No Yes Yes Yes
Mermaid Diagrams Yes Yes No No No No Yes No
Underline No No No Yes No Yes Partial No
Spoiler Text No No Yes Yes No No No No

* Slack uses single asterisks for bold (not double) and single underscores for italic. ** Slack uses <url|text> syntax instead of standard markdown links.


GitHub Flavored Markdown

GitHub Flavored Markdown (GFM) is the most influential markdown dialect. Because GitHub is the default home for open-source projects, GFM conventions have become the de facto standard.

GFM adds the following on top of standard markdown:

GitHub Alerts

A special blockquote syntax for callouts. Five types are supported:

> [!NOTE]
> Useful information that users should know.

> [!TIP]
> Helpful advice for doing things better.

> [!IMPORTANT]
> Key information users need to know.

> [!WARNING]
> Urgent info needing immediate attention.

> [!CAUTION]
> Advises about risks or negative outcomes.

Each renders with a distinct color and icon on GitHub.

Markdown Autolinked References

Inside GitHub repos, certain patterns become links automatically:

  • #123 → links to issue or pull request #123
  • @username → mentions a user
  • org/repo#123 → links to an issue in another repo
  • a1b2c3d → links to a commit hash

Markdown Mermaid Diagrams

Fenced code blocks with mermaid as the language render as flowcharts, sequence diagrams, and more:

```mermaid
graph LR
    A[Start] --> B{Decision}
    B -->|Yes| C[Do the thing]
    B -->|No| D[Skip it]
```

Markdown Math Expressions

GFM supports LaTeX math in two forms:

Inline math: $E = mc^2$

Block math:

$$
\frac{n!}{k!(n-k)!} = \binom{n}{k}
$$

Platform-Specific Markdown

Discord Markdown

Discord uses its own markdown variant. Key differences from standard:

  • __underline__ (double underscores) produces underline, not bold
  • **bold** still works
  • *italic* and _italic_ both work
  • ||spoiler|| hides text until clicked
  • # Heading works, but only H1, H2, and H3 are supported
  • Code blocks and inline code work normally
  • No tables, no images via markdown syntax

Slack Markdown (mrkdwn)

Slack's markdown flavor, confusingly called "mrkdwn," diverges significantly:

  • *bold* uses single asterisks (not double)
  • _italic_ uses single underscores
  • ~strikethrough~ uses single tildes
  • `code` works normally
  • > quote works normally
  • Links use <https://example.com|link text> syntax
  • No headings, no tables, no task lists

If you're pasting standard markdown into Slack, it won't format correctly. Convert first.

Reddit Markdown

Reddit supports most standard and extended syntax with a few quirks:

  • >!spoiler!< for spoiler text
  • ^superscript with a caret (no closing caret needed for single words)
  • Supports tables, strikethrough, and code blocks
  • Does not support task lists, footnotes, or custom heading IDs

Notion Markdown

Notion supports markdown input but converts it to its block system. You can type markdown to create blocks quickly:

  • Standard markdown works during input
  • Notion adds its own features (databases, toggles, callouts) that aren't standard markdown
  • Pasting markdown content generally imports cleanly

Obsidian Markdown

Obsidian is a note-taking app that uses markdown, with several extensions:

  • [[Wiki-style links]] for internal links between notes
  • [[Note#heading]] to link to a specific heading in another note
  • ![[Note]] to embed another note's content
  • > [!note] Callout title for Obsidian callouts (similar to GitHub alerts)
  • Full LaTeX math support
  • Full Mermaid support

Common Markdown Mistakes

Even experienced writers make these markdown mistakes. Here's what to avoid and how.

1. Missing blank lines around markdown block elements

Lists, headings, code blocks, and blockquotes usually need a blank line before and after. Without it, some parsers merge them into the surrounding paragraph.

Wrong:

Here is a paragraph.
## Heading
More text.

Right:

Here is a paragraph.

## Heading

More text.

2. Inconsistent markdown list indentation

Nested lists need consistent indentation. Mixing two-space and four-space indents, or mixing tabs and spaces, produces unpredictable results. Pick one and stick with it.

3. Forgetting trailing spaces for markdown line breaks

If you want a line break within a paragraph but your text runs together, you probably forgot the two trailing spaces. This is the single most common markdown question on Stack Overflow.

4. Relative markdown image paths breaking after deployment

![logo](images/logo.png) works in your editor but breaks when deployed to a subdirectory. Use site-absolute paths (/images/logo.png) or fully qualified URLs for portability.

5. Using Word-style smart quotes in markdown code blocks

When you paste code from a document that has curly quotes (" instead of "), the code won't work when copied. Always paste code as plain text into markdown files.

6. Mixing HTML and markdown inside the same block

Markdown inside HTML block-level tags often doesn't render. This fails:

<div>
**This bold won't render.**
</div>

Fix it by separating them with blank lines, or by using inline HTML only:

<div>

**This bold will render.**

</div>

7. Skipping markdown heading levels

Going from H1 directly to H3 lowers the level of accessibility, and hurts SEO. Use heading levels sequentially.

8. Using underscores inside words in markdown

un_believ_able produces italics in some parsers and literal underscores in others. Use asterisks for mid-word emphasis: un*believ*able.


Frequently Asked Questions About Markdown

What is markdown used for?

Markdown is used for documentation (READMEs, API docs, wikis), blog posts, technical writing, note-taking, chat messages on platforms like Discord and Slack, static websites, e-books, and anywhere plain-text formatting is useful. Most large language models output responses in markdown by default.

Is markdown the same on every platform?

No. The basic syntax (headings, emphasis, lists, links, code, blockquotes) works almost everywhere, but extended features like tables, footnotes, task lists, and math vary significantly between platforms. See the compatibility matrix above for more info.

What file extension does markdown use?

.md is the most common. You may also see .markdown, .mdown, .mkd, or .mkdn. They're all the same format. The MIME type is text/markdown, registered in RFC 7763.

Can I use HTML inside markdown?

Yes. Nearly every markdown processor passes raw HTML through to the output. This is how people add features markdown doesn't support natively, such as <kbd> tags for keyboard keys, <details> for collapsible sections, <iframe> for embeds, and more.

How do I convert markdown to PDF, Word, or HTML?

To HTML: Every markdown processor does this natively. Pandoc, markdown-it, and marked are popular libraries.

To PDF: Use Pandoc (pandoc input.md -o output.pdf), Typora's export feature, or VS Code with the Markdown PDF extension.

To Word (.docx): Pandoc handles this cleanly with pandoc input.md -o output.docx.

Does markdown support math equations?

Not in the original specification, but many processors (GitHub, GitLab, Obsidian, MkDocs, Jupyter, Notion) support LaTeX math. Use $...$ for inline math and $$...$$ for block equations.

How is markdown different from HTML?

HTML uses tags (<p>, <strong>, <a>) that are verbose but precise. Markdown uses punctuation symbols that are quick to type and stay readable in plain-text form. Every markdown file is ultimately converted to HTML for display. Markdown is a superset of HTML. You can always drop HTML into a markdown file when you need something markdown can't express.

What is CommonMark?

CommonMark is a standardized specification for markdown, published in 2014 to resolve ambiguities in Gruber's original spec. Most processors implement CommonMark as their base, then add extensions (tables, task lists, etc.) on top. GitHub Flavored Markdown is CommonMark plus GitHub's extensions.

Is markdown free?

Yes. Markdown is not software. It's a specification. Both the original Gruber specification and the CommonMark specification are freely available. The name "Markdown" itself is not trademarked.

How long does it take to learn markdown?

The basics (headings, bold, italic, links, lists) take about five minutes. You can write useful markdown within an hour. Mastering extended syntax and platform-specific variations takes longer, but this cheatsheet covers nearly everything you'll ever need.

What's the difference between markdown and rich text?

Rich text formats (.docx, .rtf) store formatting as binary or XML data alongside the text. Markdown stores formatting as visible plain-text symbols. The tradeoff: rich text gives you pixel-perfect control at the cost of portability; markdown gives you portability and speed at the cost of fine-grained control.