Skip to content
Back to Journal
GuideMay 5, 2026·5 min read

How to Escape Special Characters in Markdown

Display literal asterisks, hashes, backticks, and other special characters in markdown using the backslash escape.

The quick answer: Put a backslash (\) before a special character to display it as literal text instead of triggering markdown formatting. This is called a backslash escape.

The Backslash Escape

The backslash character (\) acts as an escape signal — it tells the markdown parser to treat the next character as plain text rather than syntax: \ → renders as (literal asterisk, not italic marker) \# → renders as # (literal hash, not a heading) \_ → renders as _ (literal underscore, not emphasis) \[ → renders as [ (literal bracket, not start of a link) \| → renders as | (literal pipe, not a table delimiter) \\ → renders as \ (literal backslash)

The Full List of Escapable Characters

These characters have special meaning in markdown and can be escaped with \ (see the Markdown escape characters reference for full details): \ * _ { } [ ] ( ) # + - . ! |`

Context Matters

Not every special character needs escaping everywhere. Context determines whether a character is interpreted as syntax:

  • # needs escaping only at the start of a line (where it would become a heading). #hashtag mid-sentence renders literally without any escaping.
  • - needs escaping only at the start of a line followed by a space (where it would become a bullet list item).
  • . after a number needs escaping only when you don't want an ordered list: 2026\. A great year.

Escaping Backticks

Backticks are special: you can't simply backslash-escape a backtick inside a code span because the backtick is both the delimiter and the content.

Single Backtick in Inline Code

Use double backticks as the delimiter to include a single backtick inside the code span:

`` code with backtick` ``

Backtick in Prose (Not Code)

To display a single backtick outside of a code context, use the backslash escape: \ → renders as `

Code Blocks: No Escaping Needed

Inside backtick code spans (`inline`) and fenced code blocks, everything is displayed verbatim. The parser does zero markdown processing inside code blocks:

``` ```text This is not bold * This is not a list item ``` ```

This is why code blocks are the best way to show literal markdown syntax in documentation — no escaping required.

Platform-by-Platform Breakdown

GitHub and GitLab

Full support for all backslash escapes. GitHub respects all 19 escapable characters defined in the CommonMark spec.

Obsidian

Full CommonMark escape support. In Obsidian's live preview, escaped characters render immediately so you can see the literal character in the editor.

Notion

Notion supports backslash escaping in its markdown import mode. In the Notion editor UI, special characters in text blocks are automatically handled.

Discord

Discord supports backslash escaping for its mrkdwn-style formatting characters (, _, ~~, etc.). Use \text\* to display literal asterisks in Discord.

Slack

Slack supports backslash escaping for its mrkdwn formatting characters.

Common Use Cases

Displaying Literal Asterisks

You're writing about math and want to show multiplication without triggering italic: 5 \ 3 = 15 renders as 5 3 = 15

Literal Hash at Start of Line

\# Not a heading renders as "# Not a heading" in plain text

Pipe Characters in Table Cells

If your table cell content contains a |, escape it: | Item | A | B | — code span handles it or | Item | A \| B | — backslash escape

Ordered List That Starts With a Number

To prevent 2026. A great year. from becoming a numbered list item: 2026\. A great year. renders as plain text

Showing Raw Markdown Syntax in Documentation

When writing markdown documentation (like this guide), showing bold as literal text requires either escaping (\\bold\\) or wrapping in a code span (`bold`). Code spans are generally cleaner.

Common Mistakes

Over-Escaping

You don't need to escape characters that aren't actually triggering formatting. \.com is unnecessary — .com renders literally without escaping because a period mid-word isn't a markdown marker.

Escaping Inside Code Blocks

Never put escape backslashes inside code blocks — they display as literal backslashes since code blocks are escape-free zones.

Wrong: Backslash for Newline

first line\ → this creates a hard line break in GFM (GitHub Flavored Markdown), not an escaped character. Don't confuse the line-break backslash with the escape backslash.

Showing a Literal Backslash

To display a single backslash in the output, write two backslashes: \\ → renders as \

The first backslash escapes the second, and the result is a single literal backslash character.


Full reference: Markdown Escape Characters.

Ready to put this into practice? Paste your markdown into the free MarkdownTools PDF exporter or HTML converter — no signup required.

Frequently Asked Questions

How do you display a literal asterisk in markdown?

Put a backslash before it: \* renders as a literal asterisk instead of starting italic or bold formatting.

How do you escape a backtick in markdown?

Use double backticks as the delimiter for your code span: `` `code` `` — this lets you include a backtick inside the code span. For a standalone literal backtick in prose, use \` (backslash + backtick).

Which characters need to be escaped in markdown?

Characters with special meaning: \ ` * _ { } [ ] ( ) # + - . ! | These only need escaping in contexts where they would otherwise trigger formatting — for example, # only needs escaping at the start of a line.

Do you need to escape special characters inside a code block?

No. Inside backtick code spans and fenced code blocks, all characters are displayed verbatim. No escaping is needed or used within code blocks.

MT

MarkdownTools Team

May 5, 2026

Try it free

Make your AI output beautiful

Paste markdown from ChatGPT or Claude. Pick a theme. Export as PDF or HTML in seconds.

Open App — It's Free