Markdown Escape Characters — How to Show Literal *, #, and More
How to escape special characters in Markdown — with copy-paste examples
The Backslash Escape
Markdown treats characters like *, _, #, and [ as formatting instructions. To show one of them literally, put a backslash \ in front of it. The backslash disappears from the output and the character is displayed as plain text.
*not bold*
\*not bold\*
Without the backslashes, *not bold* would render as not bold in italics and the asterisks would vanish. With them, the asterisks stay visible.
Complete List of Escapable Characters
These are the characters you can escape with a backslash. Each one has a special meaning in Markdown syntax.
| Character | Name | Markdown meaning | Escaped form |
|---|---|---|---|
\ | Backslash | Escape character | \\ |
` | Backtick | Inline code and code blocks | \` |
* | Asterisk | Bold, italic, bullet lists | \* |
_ | Underscore | Bold, italic | \_ |
{} | Curly braces | Extended syntax in some processors | \{\} |
[] | Square brackets | Links, images, footnotes | \[\] |
() | Parentheses | Link and image URLs | \(\) |
# | Hash | Headings | \# |
+ | Plus sign | Bullet lists | \+ |
- | Minus / hyphen | Bullet lists, horizontal rules | \- |
. | Dot | Ordered lists (1.) | \. |
! | Exclamation mark | Images () | \! |
| | Pipe | Table columns | \| |
~ | Tilde | Strikethrough | \~ |
\\ \` \* \_ \{ \} \[ \] \( \) \# \+ \- \. \! \| \~
You do not need to escape every one of these everywhere. Most only matter in a specific position, such as # at the start of a line or . after a number at the start of a line. See the practical examples below.
Practical Examples
Here are the situations where you are most likely to need an escape.
Show literal **text** without bold
Escape both the opening and the closing asterisks. Each asterisk needs its own backslash.
**text**
\*\*text\*\*
Write #hashtag without creating a heading
A hash followed by a space at the start of a line becomes a heading. In CommonMark, #hashtag with no space is already plain text, but some older processors still treat it as a heading, so escaping is a safe habit. It is required when a line starts with # and a space.
#hashtag
# Not a heading
\#hashtag
\# Not a heading
Display 1. item without starting a numbered list
A number followed by a dot and a space at the start of a line becomes an ordered list. Escape the dot, not the number.
1. item
1\. item
Show [text] without creating a link
Square brackets can start a link or a reference. Escape both brackets to keep them as plain characters.
[text](not a link)
\[text\](not a link)
Use a pipe | in text
Outside of tables, a pipe is just a regular character and needs no escape. Inside a table cell it would be read as a column separator, so escape it there.
| Operator | Meaning |
|---|---|
| a | b | a OR b |
| Operator | Meaning |
|----------|---------|
| a \| b | a OR b |
Code Blocks as an Alternative
Anything inside backticks or a fenced code block is not processed for Markdown syntax. If you have a lot of special characters to show, wrapping them in code is often easier than escaping each one.
**bold** # heading [link](url) 1. item
`**bold** # heading [link](url) 1. item`
For multiple lines, use a fenced code block with three backticks on their own lines. Code is displayed in a monospace font, so use it when that look is acceptable. If you need plain proportional text, escape with a backslash instead.
HTML Entities as an Alternative
Most Markdown processors pass HTML entities through to the output, so you can write a special character as an entity. This is useful when a backslash does not work, for example in a processor that does not support escaping a particular character.
| Entity | Result |
|---|---|
& | & |
< | < |
> | > |
* | * |
& < > *
Numeric entities work for any character: * is the asterisk, # is the hash, and | is the pipe. Entities are not interpreted inside code spans or code blocks, where they are shown as typed.
Platform Support
Backslash escaping is part of the original Markdown specification and of CommonMark, so it works everywhere Markdown is rendered: GitHub, GitLab, Bitbucket, Slack, Discord, Reddit, Stack Overflow, VS Code, Obsidian, Bear, iA Writer, Typora, and MDViewer. A few characters, such as ~ and |, belong to extensions like GitHub Flavored Markdown, so they only matter on platforms that support those extensions.
Common Mistakes
Escaping characters that do not need it
A backslash only removes special meaning from punctuation. Placing one before an ordinary letter or number does nothing useful, and the backslash is shown in the output. Only escape a character when it would otherwise be read as formatting.
| Markdown | Result |
|---|---|
\*star\* | *star* |
\hello | \hello |
\*star\*
\hello
Forgetting to escape the backslash itself
To show a literal backslash, double it: \\. This matters most when a backslash comes right before a special character, such as in Windows paths or regular expressions.
C:\Users\*.txt
C:\\Users\\\*.txt
Escaping inside code blocks
Code spans and fenced code blocks are not processed, so a backslash inside them is not an escape. It is shown as a literal backslash. Write the text exactly as you want it displayed.
\*not bold\* ← shows the backslashes
`\*not bold\*` <-- backslashes are shown
`*not bold*` <-- correct inside code
FAQ
How do I show a literal asterisk in Markdown?
Put a backslash before it: \*. For example, \*not bold\* renders as *not bold* with the asterisks visible. You can also wrap the text in backticks to show it as code, or use the HTML entity *.
What characters need to be escaped in Markdown?
The characters you can escape with a backslash are \ ` * _ {} [] () # + - . ! | ~. You only need to escape them when they would otherwise be read as formatting, such as an asterisk that could start italics, a hash at the start of a line, or a number followed by a dot at the start of a line.
Do I need to escape characters inside code blocks?
No. Text inside backticks and fenced code blocks is not processed as Markdown, so special characters appear exactly as typed. Adding a backslash inside a code block is unnecessary, and the backslash will show up in the output.
Preview Your Markdown with MDViewer
MDViewer is a native macOS app for reading and previewing Markdown files. Double-click any .md file in Finder and see it rendered instantly — escaped characters, bold, italic, tables, code blocks, and more. Lite is free; Pro adds editing, Git history, and PDF export.
Requires macOS 13.0 or later. Intel and Apple Silicon.