Backslash Escape / Unescape
Escape and unescape backslash sequences for Common, JSON and JavaScript strings
Related Tools
About Backslash Escape / Unescape
Escaping turns characters that cannot appear literally in a string, such as line breaks, tabs, quotes and backslashes, into visible backslash sequences like \n, \t and \". Unescaping reverses the process. Escaping rules differ between languages, so the tool offers three modes instead of one transform that pretends to fit everything.
How to use
- 1.Choose Escape or Unescape.
- 2.Pick Common, JSON String or JavaScript.
- 3.Paste text or load an example; the output updates as you type.
- 4.Review the character and escape counts, then copy or download the output.
- 5.Select Swap to send the output back as input and reverse the direction.
Modes
Common escapes backslashes, quotes and control characters, and reads \n \r \t \b \f \v \0 \' \" \/ \xHH \uXXXX and \u{...}; unknown escapes are reported, or kept with the Advanced option. JSON String matches JSON.stringify output and only accepts the escapes JSON allows. JavaScript adds \v, \0, \xHH, \u{...} and line continuations, rejects octal escapes as strict mode does, and lets other escaped characters stand for themselves.
Errors and limits
Invalid input never produces partial output: the tool reports the line, column and offending sequence, such as a trailing backslash, \x without two hex digits or a malformed \u. A JSON or JavaScript string pasted with its surrounding double quotes is unwrapped. Text is scanned by a small hand-written parser in your browser; nothing is evaluated as code. Input is limited to 2,000,000 characters.
