Escaping Characters in Markdown

Updated

Escape a character in Markdown by putting a backslash in front of it: \* displays a literal asterisk instead of starting italics. In CommonMark and GitHub Flavored Markdown, any ASCII punctuation character can be backslash-escaped. Inside inline code and code blocks no escaping is needed, because everything there is already shown literally.

Backslash escapes

A backslash tells the parser to treat the next character as plain text. Use it whenever a character would otherwise trigger formatting: an asterisk around a word, a hash at the start of a line, or a number followed by a period that would start a list.

\*not italic\*
\# Not a heading
2026\. A line that starts with a year
\[not a link\](https://example.com)
\_\_init\_\_.py

Characters you can escape

CommonMark allows a backslash before any ASCII punctuation character: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~. A backslash before anything else, such as a letter, is shown literally. These are the ones you will actually need:

CharacterWriteEscape it when
* asterisk\*Text would turn italic or bold, or a line starts a list
_ underscore\_Underscores surround a word (_name_)
# hash\#A line starts with # and should not be a heading
- + list markers\- \+A line starts with them followed by a space
. after a number1\.A line starts with a number and period
[ ] brackets\[ \]Bracketed text is followed by (…) or matches a reference
< > angle brackets\< or &lt;Text looks like an HTML tag
` backtick\`A literal backtick appears in normal text
| pipe\|Inside a table cell
\ backslash\\You want the backslash itself to show
~ tilde\~Paired tildes would strike text through

Angle brackets: showing <> in Markdown

Markdown passes HTML through, so a < followed by letters looks like a tag. GitHub removes tags it does not recognize, which means List<String> can render as just "List". Escape the opening bracket, use the HTML entity &lt;, or put the text in inline code.

List\<String\>
List&lt;String&gt;
`List<String>`
\<br> shows the tag instead of breaking the line

Square brackets that are not links

Brackets only become a link when followed by a URL in parentheses or when the text matches a reference definition, so [draft] on its own usually displays fine. Escape them when parentheses follow, or at the start of a list item where "[ ]" would turn into a checkbox.

\[1\](see appendix) stays as text
- \[ \] literal brackets, not a task list checkbox

Backticks inside code

Backslash escapes do not work inside code spans. The backslash is shown as-is. To show a backtick inside inline code, wrap the code in two backticks with spaces inside. To show a fenced block inside a code block, use a longer fence on the outside.

`` `backtick` ``

````markdown
```js
console.log("fenced");
```
````

Pipes in tables

A pipe inside a table cell ends the cell, even inside inline code. Escape it with a backslash; GitHub Flavored Markdown removes the backslash in the output, including within code spans.

| Operator | Meaning |
|----------|---------|
| `a \| b` | Bitwise OR |
| \|\| | Logical OR |

Where backslash escapes work

Escaping is part of core Markdown, so support is nearly universal. The exceptions are places that are not rendered as Markdown at all.

PlatformBackslash escapesNote
GitHubYesNot applied in issue and pull request titles
GitLabYes-
ObsidianYesAlso needed for # tags you do not want tagged
VS Code previewYes-
RedditYes-
DiscordYese.g. \*\*not bold\*\*

Frequently Asked Questions

How do I escape an asterisk in Markdown?

Put a backslash before it: \*. For a whole word, escape both sides: \*important\* displays *important* with the asterisks visible.

How do I show angle brackets (<>) in Markdown?

Escape the opening bracket (\<tag>), use the HTML entities &lt; and &gt;, or wrap the text in backticks so it renders as code. Otherwise renderers like GitHub may treat it as an HTML tag and hide it.

How do I write a literal backslash?

Escape it with another backslash: \\ displays a single \. Inside inline code or a code block, a single backslash is shown as-is.

Why does my backslash show up inside code?

Backslash escapes do not work in code spans or code blocks. Everything inside is literal, including the backslash. Remove it; inside code you never need to escape Markdown characters.

Try it live

Paste this syntax into the free markdown to html converter and see the rendered output instantly. No signup, and everything runs in your browser.

Open Markdown to HTML Converter →

More Markdown syntax: