Skip to main content
Best Practices

How to Escape Characters in Markdown

A complete reference for escaping special characters in markdown — backslash escapes, HTML entities, and when to use each.

MarkGenie Team
3 min read
Free to read

In this article

📖 Comprehensive guide
⏱️ 3 min read
🎯 Best Practices
Advertisement

How to Escape Characters in Markdown

Markdown uses special characters for formatting. Sometimes you need them to appear literally. Here's every way to escape them.

Backslash Escape

Put a backslash \ before any special character:

markdown
\*This is not italic\*
\# This is not a heading
\[This is not a link\]

Characters You Can Escape

CharacterEscapeName
\\Backslash
``Backtick
**Asterisk
__Underscore
{ }{ }Curly braces
[ ][ ]Square brackets
( )( )Parentheses
##Hash
+ - . !+ - . !Misc
|

HTML Entities

CharacterEntityUse
&&Ampersand
<&lt;Less than
>&gt;Greater than
©&copy;Copyright
&mdash;Em dash
&#124;
Space&nbsp;Non-breaking space

Inside Code Blocks

Characters inside code blocks never need escaping — they're always literal:

markdown

This is bold syntax, not bold text. This is link syntax

Use code blocks when showing markdown syntax examples.

The Pipe in Tables

| is the trickiest — it's the table column separator. To include a literal pipe in a cell:

markdown
| Example | Code |
|---------|------|
| Logical OR | `a \| b` |
| Bitwise OR | `a &#124; b` |

Both \| and &#124; work. The HTML entity is more universally supported.

HTML in Markdown

Raw HTML passes through most processors:

markdown
<kbd>Ctrl</kbd> + <kbd>S</kbd>

Useful for: keyboard shortcuts (<kbd>), subscript (<sub>), superscript (<sup>), underline (<u>).

Quick Decision Guide

SituationSolution
Literal *\*
Literal **bold**\*\*bold\*\*
Pipe in table cell&#124;
Show markdown codeWrap in code block
Keyboard shortcut<kbd>Ctrl</kbd>

Test your escaping in MarkGenie's live preview — you'll immediately see if the character is rendering as formatting or literal text.

Ready to try it yourself?

Put these tips into practice with MarkGenie's live markdown editor

Was this article helpful? Let us know!