How to escape characters in Markdown
Try it — edit the markdown and watch the preview
Result
Runs entirely in this tab. Open the full editor to work on a real document.
A backslash before a Markdown character makes it literal:
\*not italic\*
\# not a heading
\[not a link\]
The backslash disappears and the character is rendered as text.
What can be escaped
Only characters that mean something in Markdown:
\ ` * _ {} [] () # + - . ! |
Put a backslash in front of anything else and the backslash itself shows up, so
\a renders as \a.
Often a code span is better
If the text is code, a path, a command or a literal value, backticks beat escaping:
Use `*` for a bullet.
Open `C:\Users\me\notes.md`.
Nothing inside a code span is interpreted, so you escape nothing — and the reader gets a clearer signal about what the text actually is.
Escapes do not work inside code
A code block is verbatim, so a backslash inside one stays a backslash. That is the whole point: you should be able to paste code containing any characters at all and have it come out unchanged.
Pipes in tables
Inside a table cell, an unescaped | ends the cell. Escape it as \| even
within a code span, because the table is parsed into cells before the cell
contents are parsed.
Common questions
- How do I show a literal asterisk or underscore?
- Put a backslash in front of it — \* or \_. The backslash is consumed and the character is rendered as text rather than treated as a formatting marker.
- Which characters can be escaped?
- The ones with meaning in Markdown — backslash, backtick, asterisk, underscore, curly braces, square brackets, parentheses, hash, plus, minus, dot, exclamation mark and pipe. Escaping a character with no special meaning leaves the backslash visible.
- When should I use a code span instead?
- Whenever the text is code, a path or a literal value. Inside backticks nothing is interpreted, so you escape nothing and the reader gets a clearer signal about what the text is.
- How do I write a literal backslash?
- Double it — \\ renders as one backslash. This bites when documenting Windows paths, where a code span is almost always the better answer.
- Why does my escape not work inside a code block?
- Because escapes are not processed there. A code block is verbatim by definition, so a backslash inside one stays a backslash. That is the point of code blocks.