Markdown Escape Characters: The Complete Guide

Ever run into this — you type *hello* in Markdown, and it renders as hello (italic)? Or you write # Heading, and it gets treated as an actual heading?

That's Markdown's "special characters" at work. Symbols like asterisks, hash signs, and square brackets all have formatting roles in Markdown. If you want them to show up as plain text, you need Markdown escaping.

What Is Markdown Escaping?

The concept is simple: place a backslash \ before a special character to tell the Markdown parser, "Don't process this symbol — display it as-is."

For example:

\*This is not italic\*

The rendered result: *This is not italic* (the asterisks display literally, no italic formatting).

This rule dates back to Markdown's original design — John Gruber defined the backslash escape mechanism in the original syntax documentation [^1].

Which Characters Can Be Escaped? Complete List

Here are all the characters Markdown supports for escaping:

CharacterNameCommon Use
\BackslashEscaping itself
`BacktickInline code
*AsteriskBold/italic
_UnderscoreBold/italic
{}Curly bracesSome extended syntax
[]Square bracketsLinks/images
()ParenthesesLinks
#Hash signHeadings
+Plus signUnordered lists
-Hyphen/minusUnordered lists/horizontal rules
.PeriodOrdered lists
!Exclamation markImages
|PipeTables (extended syntax) [^2]

That's 13 characters total (the pipe | is supported in some parsers). Admittedly, it's a short list, but it covers virtually every symbol that could "cause trouble."

The Special Case of the Pipe Character

The pipe | deserves a separate mention. It has no special meaning in standard Markdown, but if you're using table syntax (a GitHub Flavored Markdown extension), the pipe serves as the column separator. So to display a pipe inside a table cell, you need to escape it:

| Command | Description |
|---------|-------------|
| `ls \| grep test` | List files and filter |

However, pipes inside code blocks don't need escaping — more on that later.

Common Escaping Scenarios

Displaying Asterisks and Underscores

This is the most common scenario. When writing math formulas or plain text, you often need to display raw asterisks or underscores:

Score calculation: score \= 100 \* 0.8 \+ 20

File path: C:\\Users\\\_alice\\\_docs

In the rendered output, asterisks and underscores display literally — they won't be parsed as bold or italic.

Displaying Hash Signs (Without Creating Headings)

When discussing issue numbers, color codes, or similar scenarios, you frequently need to display #:

Today's issues are \#42 and \#108

Background color uses \#FFFFFF

Displaying Square Brackets and Parentheses

When you want to show the link syntax itself rather than an actual link:

Link syntax format: \[display text\]\(URL\)

Escaping Without Backslashes

Backslashes are the most common way to escape, but they're not the only option. Depending on the situation, there are a few alternatives.

Wrapping in Inline Code

Place content inside backticks `, and no special characters will be parsed:

`**Not bold**`  → **Not bold** (displayed literally)

`# Not a heading`    → # Not a heading

`[Not a link](url)` → [Not a link](url)

This is the approach I recommend most — when you just want a fragment to display as-is, inline code is far more convenient than adding backslashes to each character. Especially when writing technical documentation, code is already marked with backticks, so it serves double duty.

Using Code Blocks

For multi-line content that needs to display literally, use a triple-backtick code block:

```markdown
**This text won't be bold**
## This is not a heading
[This is not a link](https://example.com)

Inside a code block, all Markdown formatting is disabled. Every character displays as-is — no escaping needed.

### Using HTML Entities

For `<` and `>`, HTML entities can sometimes be more reliable:

```markdown
&lt;div&gt;     → <div> (displayed literally)

5 &gt; 3       → 5 > 3

The HTML entity &lt; represents <, and &gt; represents > [^3]. In some parsers, writing < directly might be treated as an HTML tag — using entities avoids this issue.

Nested Code Blocks: A Common Pitfall

This topic goes a bit deeper. When you need to "display Markdown code inside Markdown" — that is, a code block containing another code block — you run into nested escaping issues.

The Basic Approach: Use More Backticks

Use more backticks for the outer code block than the inner one. If the inner block uses three backticks, the outer block uses four:

````markdown
```javascript
console.log("hello");

Another Option: Use Tildes

Besides backticks, you can use ~~~ as code block delimiters, which avoids conflicts with backticks:

```javascript
console.log("hello");
```

I once ran into this while writing a tutorial on GitHub — nesting three backticks completely broke the rendering. Switching to four backticks fixed it. Honestly, this problem doesn't come up often, but when it does, it's a real headache — Rick Strahl discussed this "Russian nesting doll" approach in detail on his blog [^4].

Escaping Backticks Inside Inline Code

This is a classic Stack Exchange question with over 370K views [^5]. Inside inline code, you can't use backslashes to escape backticks (because inline code doesn't process escapes). The solution is to wrap with double backticks:

`` ` ``  → ` (displays one backtick)
`` `` ` `` ``  → `` ` `` (displays two backticks)

Note the space between the double backticks and the content — this prevents the opening backtick from being treated as the closing delimiter.

Differences Across Platforms

This is something many people overlook: different Markdown parsers have different levels of escape support.

CharacterCommonMarkGFM (GitHub)ObsidianTypora
Basic escapes (13 chars)
Pipe \|
Escaping inside tables⚠️ Partial
Line-end \ line break
Escaped space✅ (non-breaking)

Most basic escapes work correctly across all platforms. Differences mainly show up in edge cases like escaping inside tables and certain extended syntax features. Yihui also noted in the R Markdown Cookbook that escaped spaces produce "non-breaking spaces," and this behavior may vary slightly across environments [^6].

Common Questions

What If Escaping Doesn't Work?

First, check two things:

  1. Did you add the backslash inside a code block? Backslashes inside code blocks are not interpreted as escapes — they're just regular characters. To display a backslash in a code block, just type it directly; no extra escaping needed.

  2. Is the character after the backslash escapable? Markdown only works for the 13 characters in the list above. If you write \a or \b, both the backslash and the letter display as-is with no change.

How Do You Display a Backslash Itself?

Escaping a backslash is simply two backslashes:

\\ → \

To display multiple backslashes, use them in pairs: \\\\\\.

What Does a Trailing Backslash Mean?

A backslash at the end of a line means "soft line break" — it continues the current paragraph on the next line rather than starting a new paragraph:

This is a very long line of text,\
but it will render as a single continuous paragraph.

This usage comes from the CommonMark specification and is supported in GitHub, Obsidian, and Typora [^1].

How Do You Display Pipe Characters in Tables?

To display a pipe inside a table cell, escape it with a backslash:

| Expression | Description |
|------------|-------------|
| `a \|\| b` | Logical OR |

Alternatively, wrap the pipe-containing content in code markers (inline code or code blocks), which also avoids manual escaping.

Quick Reference Table

Here's a quick reference for when you need it:

Character to DisplaySyntaxNotes
\\\Backslash
` | \` or double backtick wrappingBacktick
*\*Asterisk
_\_Underscore
#\#Hash sign
+\+Plus sign
-\-Hyphen
.\.Period
!\!Exclamation mark
[]\[ \]Square brackets
()\( \)Parentheses
{}\{ \}Curly braces
\|\|Pipe
<&lt;HTML entity
>&gt;HTML entity

Related Content


[^1]: John Gruber, "Markdown Syntax Documentation," Daring Fireball. https://daringfireball.net/projects/markdown/syntax[^2]: Markdown Guide, "Basic Syntax." https://www.markdownguide.org/basic-syntax[^3]: MDtoLink Blog, "Markdown Escape Characters: The Complete List." https://mdtolink.com/blog/markdown-escape-characters/[^4]: Rick Strahl, "Escaping Markdown Code Snippets and Inline Code as Markdown," West Wind Weblog, 2022. https://weblog.west-wind.com/posts/2022-Feb-16-Escaping-Markdown-Code-Snippets-and-Inline-Code-as-Markdown[^5]: Stack Exchange Meta, "How do I escape a backtick within in-line code in Markdown?" https://meta.stackexchange.com/questions/82718[^6]: Yihui Xie, "Special Characters," R Markdown Cookbook. https://yihui.org/rmarkdown-cookbook/special-chars