Escape or unescape backslashes, quotes, newlines, tabs, and control characters for source-safe strings.
Loading tool
About Backslash Escape / Unescape
Escape raw text into a string literal you can paste into JavaScript, JSON, Java, C# and similar languages, or unescape a literal back into raw text. Escaping covers backslashes, newlines, tabs, \0, \b, \f, \v, quotes and other control characters (as \uXXXX), with an option to escape every non-ASCII character too. Unescaping understands \xHH, \uXXXX and \u{...} sequences and warns about invalid ones.
Common uses
- Turn a multi-line message or Windows path into a single-line string literal for source code.
- Read a log line or JSON value full of \n and \" escapes as plain text.
- Produce an ASCII-only literal by converting accented characters and emoji to \uXXXX.
- Choose whether to escape double quotes, single quotes, both or neither to match your quoting style.
FAQ
- What does it mean to escape a string?
- Escaping replaces characters that have special meaning inside a string literal, such as quotes, backslashes and line breaks, with backslash sequences like \", \\ and \n so the literal parses correctly.
- Why is a backslash doubled when escaped?
- In most C-style languages a single backslash starts an escape sequence, so a literal backslash must be written as \\. A Windows path like C:\Users therefore becomes C:\\Users inside a string.
- What is the difference between \uXXXX and \u{...}?
- \uXXXX takes exactly four hex digits for one UTF-16 code unit, so characters above U+FFFF such as emoji need two of them (a surrogate pair). The ES6 form \u{1F600} accepts up to six hex digits and represents any code point directly.