DevKits
46 snippets · 13 sections

Markdown Cheat Sheet

Every Markdown syntax element on one page, with copyable snippets. Covers both CommonMark (the modern standard) and GFM (GitHub Flavored) extras — task lists, strikethrough, tables, footnotes.

Jump to a section, copy the exact snippet you need, and paste it into your README, issue tracker, or docs. For a live preview and conversion, try the Markdown to HTML tool. Building a table by hand? Use the Markdown Table Generator instead.

Headings

Two syntaxes. ATX (# style) is the modern default. Setext (=== / ---) is legacy but supported.

H1 – H6 (ATX)

# H1
## H2
### H3
#### H4
##### H5
###### H6

Setext H1 and H2

Alt-H1
======

Alt-H2
------

Only H1 and H2 have setext forms.

Closing hashes (optional)

## Also valid ##

Emphasis

Italic, bold, and combined bold-italic.

Italic

*italic* or _italic_

Bold

**bold** or __bold__

Bold + italic

***bold italic*** or ___bold italic___

Strikethrough (GFM)

~~struck through~~

GitHub Flavored Markdown. Not in the original CommonMark.

Lists

Unordered lists use -, *, or +. Ordered lists use 1., 2., etc. Nesting uses 2- or 4-space indent (depends on renderer).

Unordered

- Apple
- Banana
- Cherry

Ordered

1. First
2. Second
3. Third

Ordered starting from N

5. Five
6. Six
7. Seven

Most renderers respect the starting number but auto-increment after.

Nested lists

- Parent
  - Child
    - Grandchild

Task list (GFM)

- [x] Done
- [ ] To-do
- [ ] Another

GitHub-flavored Markdown. Renders as checkbox in GitHub UI.

Images

Same syntax as links, prefixed with !. The 'alt' text is required for accessibility.

Inline image

![Alt text](https://example.com/img.png "Optional title")

Reference image

![Alt][logo]

[logo]: https://example.com/img.png

HTML for size / attributes

<img src="pic.png" alt="Pic" width="200" />

Pure Markdown has no width / height syntax — drop to inline HTML.

Code

Inline with backticks; fenced blocks with ``` and an optional language for syntax highlighting.

Inline

Use `printf` for formatted output.

Fenced code block

```js
const answer = 42;
console.log(answer);
```

Indented code block

    // 4 spaces of indent
    def hello():
        return 'world'

Legacy. Prefer fenced.

Inline with backticks inside

``Use `code` inside``

Use double backticks (or more) to include literal backticks.

Blockquotes

Start each line with >. Nest with additional >.

Single-level

> A quoted line.

Multi-paragraph

> First paragraph.
>
> Second paragraph.

Nested

> Outer
> > Inner
> > > Deeper

Tables (GFM)

Pipe-separated. First divider row uses --- with optional :--- / :---: / ---: for alignment.

Basic table

| Name | Age | City |
|------|-----|------|
| Alice | 30 | NYC |
| Bob | 25 | LA |

Alignment

| Left | Center | Right |
|:-----|:------:|------:|
| a | b | c |

:--- left, :---: center, ---: right.

Escape pipes

| Column | Value |
|--------|-------|
| pipe | a \| b |

Escape a literal | with \| inside cells.

Horizontal rule

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

Hyphens

---

Asterisks

***

Underscores

___

Escape sequences

Backslash-escape any Markdown special character to make it literal.

Literal characters

\*not italic\* \[not a link\] \`not code\`

All escapable characters

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

Inline HTML

Any HTML is passed through as-is (in most renderers). Use it for anything Markdown can't express.

Inline element

This word is <em>emphasized</em> via HTML.

Details / summary (collapsible)

<details>
<summary>Click to expand</summary>

Hidden content.

</details>

GitHub renders this as a collapsible section. Very useful for READMEs.

Line break

Line 1<br />
Line 2

Alternative to two-space line ending. More explicit but less idiomatic.

GitHub Flavored (GFM) extras

Features from GFM that aren't in the original CommonMark. Widely supported by GitHub, GitLab, Bitbucket, and most static-site generators.

Strikethrough

~~struck~~

Task list

- [x] Done
- [ ] Not yet

Tables

| a | b |
|---|---|
| 1 | 2 |

Autolink

www.example.com and https://example.com

GFM auto-links bare URLs. CommonMark requires <url> or explicit [text](url).

Emoji shortcode (GitHub)

:smile: :rocket: :+1:

GitHub-specific. Not universally supported.

Footnotes

Here is a claim[^1].

[^1]: With a footnote.

GFM 2021+. Supported by most modern renderers.

Line breaks

Markdown collapses single newlines into spaces by default. For a hard line break, end a line with two spaces OR use <br />.

Paragraph break

Paragraph one.

Paragraph two.

Hard break (two-space ending)

Line 1  
Line 2

Two trailing spaces before the newline. Invisible → error-prone. Prefer <br />.

Hard break (HTML)

Line 1<br />
Line 2

CommonMark vs GitHub Flavored Markdown

Markdown isn't one single spec. CommonMark is the strict, unambiguous standard that most modern parsers implement — it defines headings, emphasis, lists, links, images, code, and blockquotes. GitHub Flavored Markdown (GFM) is a superset that adds the features you use every day in READMEs and issues: tables, task lists, strikethrough, autolinked URLs, and footnotes. Throughout this cheat sheet, GFM-only syntax is labeled so you know what will render outside GitHub. When in doubt, paste a snippet into the live Markdown preview to confirm it renders the way you expect.

Frequently Asked Questions

What is the difference between CommonMark and GitHub Flavored Markdown (GFM)?

CommonMark is the strict, unambiguous Markdown specification that most modern parsers implement — it covers headings, emphasis, lists, links, images, code, and blockquotes. GFM is GitHub's superset that adds tables, task lists ([ ] / [x]), strikethrough (~~text~~), autolinks for bare URLs, and footnotes. Everything on this cheat sheet is marked when it's GFM-only so you know what will and won't render outside GitHub.

How do I write a table in Markdown?

Separate columns with pipes (|) and add a divider row of dashes under the header: `| Name | Age |` then `|------|-----|`. Control alignment with colons in the divider — `:---` for left, `:---:` for center, `---:` for right. Tables are a GFM feature, so test them in your target renderer. See the Tables section above for copy-paste examples.

How do I add a code block with syntax highlighting?

Wrap the code in a fenced block using three backticks and put the language name right after the opening fence, e.g. ```js on its own line, your code, then ``` to close. Most renderers (GitHub, GitLab, static-site generators) use the language hint to apply syntax highlighting. For inline code, wrap a short snippet in single backticks.

How do I create a hard line break in Markdown?

Markdown collapses single newlines into spaces. For a hard line break, either end the line with two trailing spaces before the newline, or use an explicit <br /> tag. Two trailing spaces are invisible and error-prone, so <br /> is usually safer. For a new paragraph, leave a blank line between blocks.

Can I use HTML inside Markdown?

Yes — most renderers pass raw HTML through as-is, so you can drop to HTML for anything Markdown can't express: image width/height (<img width="200">), collapsible sections (<details><summary>), or inline styling. Note that some platforms sanitize or strip HTML for security, and untrusted Markdown with raw HTML can be an XSS vector.

How do I write a checklist (task list) in Markdown?

Use a list item with a bracketed checkbox: `- [x] Done` for a checked item and `- [ ] To-do` for an unchecked one (note the space inside the empty brackets). Task lists are a GitHub Flavored Markdown extension — they render as interactive checkboxes in GitHub issues and PRs but show as plain text in strict CommonMark renderers.

Try Markdown live

Paste any of these snippets into a live tool to see the rendered result and copy the resulting HTML.