Markdown Symbols: How to Escape Characters Literally

September 11, 2026 · 9 min read

Markdown Symbols: How to Escape Characters and Show Them Literally

A markdown symbol such as *, _, #, or $ tells the parser to format text. To show the symbol itself, put a backslash in front of it (\*), wrap it in backticks, or use an HTML entity. This guide lists every escapable character, explains when each method fails, and covers the dollar sign on GitHub, Jupyter, and Obsidian.

What Are Markdown Symbols?

In Markdown, symbols are the ASCII punctuation characters the parser treats as instructions. An asterisk starts emphasis, a hash starts a heading, a pipe builds a table cell. Type one where the parser expects it and your text changes shape. Type one where the parser does not expect it and it stays literal.

That second rule matters. Symbols in Markdown are context sensitive, so most of them only need escaping in a specific position:

SymbolFormats whenStays literal when
* or _Wrapped around text: *word*Surrounded by spaces: 2 * 3
#At line start followed by a spaceMid-sentence: issue #42
-, +, 1.At line start followed by a spaceMid-sentence
>At line startMid-sentence
`Anywhere, pairedNever paired
[ ] ( )In a [text](url) patternUnpaired
|Inside a table rowOutside tables
<Starting an HTML tag or autolinkFollowed by a space or digit
!Directly before [Anywhere else

The Markdown cheat sheet covers what each symbol does when it formats. This post covers the opposite job: stopping it.

Markdown Escape Characters: The Backslash Rule

The backslash is the markdown escape character. The CommonMark spec (0.31.2) states that any ASCII punctuation character may be backslash-escaped, and lists all 32 of them:

\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\`\{\|\}\~

That renders as the bare characters: !"#$%&'()*+,-./:;<=>?@[\]^_ followed by backtick, {|}~. Three rules follow from the spec:

  1. A backslash before anything else is literal. \a, \3, and \ print as typed, backslash included. You cannot escape a letter or a space.
  2. A backslash escape has no effect inside code. Code spans, fenced blocks, autolinks, and raw HTML pass the backslash through unchanged.
  3. To print a backslash, escape it. \\ renders as a single \.

Here are the escapes people reach for most, with the rendered result:

\*not italic\*          renders as   *not italic*
\# not a heading        renders as   # not a heading
1\. not a list          renders as   1. not a list
snake\_case             renders as   snake_case
\[not a link\](x)       renders as   [not a link](x)
\| not a cell           renders as   | not a cell
\\ one backslash        renders as   \ one backslash

For numbered lists, escape the period, not the digit: 1\. works, \1. prints a stray backslash. Obsidian's help page makes the same point, and it applies everywhere.

How to Write a Symbol in Markdown?

Searches for markdown how to escape usually come from one of two situations: a stray asterisk that italicised half a sentence, or a filename with underscores that vanished. You have four ways to write a symbol in Markdown without triggering it. Pick by where the symbol sits.

Backslash escape. Best for a single character inside a normal sentence. Fails inside code, where the backslash itself is printed.

Code span. Wrap the text in backticks: `*literal*`. Best when the symbol is part of code, a filename, or a command, because it also switches to a monospace font. Fails when you need the surrounding text to keep its formatting, since nothing inside a code span is parsed. To show a backtick inside a span, open and close the span with two backticks instead of one.

HTML entity. &ast; prints *, &#36; prints $, &lt; prints <. CommonMark recognises named and numeric references everywhere except inside code, per the entity references section. Best when a platform strips backslashes but keeps entities. Fails in renderers that disable HTML, and it is unreadable in the source.

Fenced code block. Best for multi-line samples: a whole config file, a regex, a Markdown tutorial like this one. Nothing inside is parsed. The Markdown code block guide covers the fence syntax and language hints.

Our rule of thumb: backslash for one symbol in prose, backticks for anything that is code, a fence for anything longer than a line. We prefer entities only as a last resort.

The Markdown $ Symbol: Prices vs Math

The dollar sign is not a special character in CommonMark. Write costs $5 and it renders as typed. The trouble starts on platforms that add math rendering, where $ opens an inline equation.

GitHub treats $...$ and $$...$$ as LaTeX math in Markdown files, issues, and comments. For a literal dollar inside a math expression, GitHub's math documentation says to write \$. For a literal dollar outside math on the same line, wrap it in span tags: <span>$</span>100.

Jupyter notebooks render $ as math in Markdown cells through MathJax. Escape with \$ or use a code span.

Obsidian does the same with its built-in MathJax. \$ works.

Stack Exchange sites with MathJax (Math, Physics, and others) treat $ as math; the general Stack Overflow site does not.

Two dollar amounts in one sentence ($5 and $10) are the classic accident on GitHub, because the parser reads everything between them as an equation. \$5 and \$10 fixes it.

If you actually want math, the Markdown equation guide covers the delimiters. If you only want prices, \$ is safe on every platform we tested, because CommonMark drops the backslash and leaves the $.

Try Markdown Escape Characters in the Editor

Each row of this table shows a symbol formatting on the left and escaped on the right. Delete a backslash to watch the formatting return.

Formatted Escaped
italic *italic*
bold **bold**
struck ~~struck~~
link [link](https://example.com)
snake_case_name snake_case_name
abc a**b**c

# Not a heading

1. Not a list item

> Not a quote

The price is $5, and 2 * 3 = 6 needs no escape.

A single backslash: \ ends the demo.

69 words393 characters18 lines
Markdown

The Markdown to HTML converter shows the exact HTML each escape produces, which is the fastest way to confirm that a backslash disappeared and the symbol survived.

Escape in Markdown on GitHub, Obsidian, Slack, and Discord

Escaping works the same in every CommonMark renderer, but each platform adds its own special symbols.

GitHub follows the spec. Two extras to know: backslash escapes do not work in issue or pull request titles, and @name and #123 create mentions and issue links inside comments. Wrap them in backticks to keep them plain. GitHub's basic formatting docs show the \*our-new-project\* example.

Obsidian adds [[wikilinks]], ==highlights==, and %%comments%%. Escape the first character of each pair (\[[, \==, \%%) to show them literally. Obsidian's help page lists \*, \_, \#, a backtick, \|, and \~ as the common escapes.

Slack does not use standard Markdown. Its composer applies its own formatting rules, and a backslash is not treated as an escape character. The reliable way to show a literal asterisk or underscore in Slack is a code span.

Discord honours backslash escapes for its formatting characters, so \* and \_ print literally in a message. Our Discord Markdown cheat sheet covers the rest of its syntax.

One acknowledged limitation: intraword underscores. CommonMark says snake_case_name stays literal because _ cannot open emphasis mid-word, while a*b*c does italicise the b. Older parsers based on the original Markdown.pl treat both the same way, so escape underscores if your target renderer is unknown.

Common Markdown Escaping Mistakes

Escaping inside a code span. `\*` prints the backslash. Remove it; code spans need no escaping.

Escaping the wrong character in a list. \1. item prints a backslash. Write 1\. item.

Using an entity inside a fence. &lt; inside a code block prints as &lt;. Fenced blocks are already literal, so type the < directly.

Forgetting the second dollar. One $ in a paragraph is harmless on GitHub. Two of them start and end an equation, so $5 to $10 becomes garbled math. Escape both.

Markdown Symbols FAQ

Every markdown symbol can be shown literally. Use a backslash for one character in prose, backticks for anything that is code, a fence for anything longer, and \$ wherever a platform renders math. Paste the table above into the editor and toggle the backslashes until the preview shows exactly what you mean.