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.

CharacterNameMarkdown meaningEscaped form
\BackslashEscape character\\
`BacktickInline code and code blocks\`
*AsteriskBold, italic, bullet lists\*
_UnderscoreBold, italic\_
{}Curly bracesExtended syntax in some processors\{\}
[]Square bracketsLinks, images, footnotes\[\]
()ParenthesesLink and image URLs\(\)
#HashHeadings\#
+Plus signBullet lists\+
-Minus / hyphenBullet lists, horizontal rules\-
.DotOrdered lists (1.)\.
!Exclamation markImages (![alt](url))\!
|PipeTable columns\|
~TildeStrikethrough\~
\\ \` \* \_ \{ \} \[ \] \( \) \# \+ \- \. \! \| \~

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.

OperatorMeaning
a | ba 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.

EntityResult
&&
&lt;<
&gt;>
&#42;*
&amp;  &lt;  &gt;  &#42;

Numeric entities work for any character: &#42; is the asterisk, &#35; is the hash, and &#124; 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.

MarkdownResult
\*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 &#42;.

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.

Download MDViewer

Requires macOS 13.0 or later. Intel and Apple Silicon.