JavaScript & Browser
JavaScript String Escaper
Turn any text into a safe JavaScript string literal, or decode an escaped literal back into readable text. Handles quotes, newlines, control characters, and Unicode — everything runs in your browser, so your input never leaves the page.
Direction & options
liveInput
textEverything is processed locally. Ctrl/ Cmd + Enter copies the result.
Output
literalWhat gets escaped
Escaping protects a backslash, the surrounding quote character, and the short escapes
\n, \r, \t, \b, \f,
and \v. Remaining control characters use \xHH, and the
JavaScript line/paragraph separators \u2028 and \u2029 are
always escaped. Enable the Unicode option to turn every non-ASCII character into a
\uXXXX escape when you need pure ASCII output.
Unescaping understands the full JavaScript string grammar: \xHH,
\uHHHH, \u{...}, line continuations, and identity escapes.
Legacy octal escapes are rejected with an explanation because they are invalid in
strict mode.