Back to blog list
· Updated ·eazydocument

How to escape LaTeX special characters in text

LaTeX ToolsAcademic Writing

Escape special characters in ordinary text

In LaTeX text, write a backslash before %, &, $, #, _, { and } when you want the literal character. Use \textbackslash{} for a literal backslash, \textasciicircum{} for ^, and \textasciitilde{} for ~. An ordinary @ in an email address does not need escaping.

Open the LaTeX text escape tool, choose Escape, and paste your plain text. Output updates immediately; there is no separate Convert step.

Copyable input and output

For this plain-text input:

A&B costs $10 (50% off). Email: user_name@example.com

Escape mode produces:

A\&B costs \$10 (50\% off). Email: user\_name@example.com

This complete document shows the result in ordinary text:

\documentclass{article}
\begin{document}
A\&B costs \$10 (50\% off). Email: user\_name@example.com
\end{document}

You can copy the output with Copy Output. Compile the document in your LaTeX editor to check the final text.

Which characters does the tool escape?

Plain characterLaTeX text form
&\&
%\%
$\$
#\#
_\_
{\{
}\}
^\textasciicircum{}
~\textasciitilde{}
backslash\textbackslash{}

For example, plain text C:\Data\results_1.csv becomes:

C:\textbackslash{}Data\textbackslash{}results\_1.csv

The tool replaces each character literally. It does not decide whether part of your input was intended as a LaTeX command.

Keep math and existing LaTeX syntax separate

Escape mode is for plain text. Do not run a complete LaTeX document or a finished equation through it: command backslashes, braces, dollar delimiters, superscripts and subscripts would also be escaped.

For an equation, x^2 + y_2 = z normally belongs in math mode:

\[
x^2 + y_2 = z
\]

Here ^ and _ are useful syntax, not literal text characters. Use the formula editor or formula preview for this task.

The escape tool preview renders the original input as math to illustrate its special meaning. It is not a preview of your full document or proof that the escaped output compiles.

Unescape, URLs and code

Recover text from escaped forms

Choose Unescape to replace the character forms listed above with their plain-text equivalents. Swap Input/Output puts the current output into the input and switches mode. Unescape handles these known replacements; it is not a general LaTeX-to-text converter and does not remove arbitrary commands.

Avoid escaping the same text twice

If the input already contains \%, Escape treats its backslash as a literal character too. Work from the original plain text, or review the existing escaping before converting it.

Format a URL

For a URL, the url package can be more convenient than manually escaping the text:

\documentclass{article}
\usepackage{url}
\begin{document}
\url{https://example.com/report_name?part=1&view=full}
\end{document}

Show a code snippet

In ordinary document text, \verb|file_name.csv| prints a short literal snippet without escaping the underscore. For multiple lines, consider the verbatim environment. These commands have restrictions in arguments such as headings and captions; check them in the context where you use them.

For a data table, the Table to LaTeX converter already escapes plain cell values. The table conversion guide shows a complete example.

Related Guides