Markdown cheat sheet
Every markdown element with the syntax on the left and the rendered result on the right. Covers core markdown, GitHub Flavored Markdown (GFM), and mermaid diagrams. Click Copy on any block to grab the snippet.
Headings
Six levels
# H1 — page title
## H2 — section
### H3 — subsection
#### H4
##### H5
###### H6H1 — page title
H2 — section
H3 — subsection
H4
H5
H6
One H1 per document is the convention. The alternative "underline" syntax (=== / ---) only covers H1 and H2 — the # form is preferred.
Emphasis
Bold, italic, both
**bold** and *italic* and ***bold italic***bold and italic and bold italic
Underscores work too (__bold__, _italic_), but asterisks survive mid-word: fan**tas**tic.
Strikethrough (GFM)
~~crossed out~~crossed out
Lists
Unordered
- First item
- Second item
- Nested (indent 2 spaces)
- Third item- First item
- Second item
- Nested (indent 2 spaces)
- Third item
Ordered
1. Step one
2. Step two
1. The numbers you type don't matter — renderers count for you- Step one
- Step two
- The numbers you type don't matter — renderers count for you
Task list (GFM)
- [x] Ship the feature
- [ ] Write the docs
- [ ] Tell someone- Ship the feature
- Write the docs
- Tell someone
Links & images
Inline link
[link text](https://docs-md.com "optional hover title")Image
An image is a link with a ! in front. Alt text matters: screen readers read it, and it shows when the image breaks.
Autolink (GFM)
Bare URLs become links: https://docs-md.comBare URLs become links: https://docs-md.com
Reference-style
Long documents read better with [named references][docs].
[docs]: https://docs-md.comLong documents read better with named references.
Definitions can live anywhere in the file — conventionally at the bottom.
Code
Inline code
Run `npm install` before `npm run dev`.Run npm install before npm run dev.
Fenced block with language
```ts
function greet(name: string) {
return `Hello, ${name}`;
}
```function greet(name: string) {
return `Hello, ${name}`;
}
The language tag after ``` turns on syntax highlighting. Common tags: js, ts, python, bash, json, sql, diff.
Fence inside a fence
````md
To show a code block inside a code block,
use more backticks on the outside:
```js
console.log("nested");
```
````Tables (GFM)
Basic table with alignment
| Left | Center | Right |
| :--- | :----: | ----: |
| a | b | c |
| d | e | f || Left | Center | Right |
|---|---|---|
| a | b | c |
| d | e | f |
Colons in the separator row control alignment. Escape literal pipes in cells as \|. Need to build one fast? Use the table generator below.
Blockquotes
Quote and nesting
> A quoted paragraph.
>
> > Nested quotes work too.
>
> Back to the first level — **formatting works inside**.A quoted paragraph.
Nested quotes work too.
Back to the first level — formatting works inside.
Structure & spacing
Horizontal rule
Above the line.
---
Below the line.Above the line.
Below the line.
Three or more hyphens on their own line, with blank lines around them (otherwise --- under text becomes an H2).
Line break vs. new paragraph
End a line with two spaces
for a line break in the same paragraph.
A blank line starts a new paragraph.End a line with two spaces
for a line break in the same paragraph.
A blank line starts a new paragraph.
A backslash at the end of a line also forces a break and is easier to see than trailing spaces.
Escaping characters
\*not italic\* and \# not a heading and \| not a table pipe*not italic* and # not a heading and | not a table pipe
Footnotes (GFM)
Footnote reference and definition
Markdown was created in 2004.[^1]
[^1]: By John Gruber, with Aaron Swartz contributing to the syntax.Supported on GitHub and most modern renderers; not part of original markdown.
Mermaid diagrams
Flowchart from a code fence
```mermaid
graph LR
A[Write markdown] --> B{Share it?}
B -->|yes| C[Get a link]
B -->|no| D[Keep local]
```Supported on GitHub, GitLab, and Docs MD share pages. Also handles sequence diagrams, gantt charts, and ER diagrams.
Inline HTML
When markdown runs out
Markdown has no underline, so use <u>HTML</u>, <sub>subscript</sub>, <sup>superscript</sup>, or <kbd>Ctrl</kbd>+<kbd>C</kbd>.Markdown has no underline, so use <u>HTML</u>, <sub>subscript</sub>, <sup>superscript</sup>, or <kbd>Ctrl</kbd>+<kbd>C</kbd>.
Most renderers pass HTML through (GitHub sanitizes scripts and styles). Collapsible sections use <details><summary>…</summary></details>.
Which markdown is this?
"Markdown" in the wild almost always means GitHub Flavored Markdown (GFM) — the original 2004 syntax plus tables, task lists, strikethrough, autolinks, and footnotes. Everything on this page renders on GitHub, GitLab, and on Docs MD share pages. The formal spec behind it is CommonMark; when two renderers disagree about an edge case, CommonMark's answer is the one to bet on.
Put it to work
Build tables visually with the table generator, turn a document into a file with the PDF converter, or share markdown as a link that renders everything on this page — including the mermaid diagrams.