Backslash Escape / Unescape

Escape and unescape backslash sequences for JavaScript, Python, Java, and C/C++.

39 chars
Escaped Output0 chars

Frequently Asked Questions

Backslash escaping is a way to represent special characters in strings using a backslash (\) followed by a code. For example, \n represents a newline, \t represents a tab, and \\ represents a literal backslash. This is essential in most programming languages for embedding special characters in string literals.
Each programming language defines its own set of recognized escape sequences. JavaScript uses \xHH for hex and \uXXXX for Unicode, Java only supports \uXXXX, C/C++ supports \xHH and octal \ooo, and Python adds \N{name} for named Unicode characters. This tool handles the differences automatically.
Characters that typically need escaping include: newline (\n), tab (\t), carriage return (\r), backslash (\\), double quote (\"), single quote (\'), null byte (\0), and any non-ASCII/non-printable characters. The exact set depends on the language and context.
\xHH represents a byte value using exactly 2 hex digits (range 00-FF), while \uXXXX represents a Unicode code point using exactly 4 hex digits (range 0000-FFFF). JavaScript and Python support both, Java only supports \u, and C/C++ primarily uses \x and octal.
When unescaping, if the tool encounters an invalid or unrecognized escape sequence, it preserves the sequence as-is rather than throwing an error. This ensures you can still work with partially escaped strings safely.