Skip to content
Jellykit

JavaScript String Escape

Escape text for a JavaScript string literal (quotes, backslashes, line breaks, \u codes) or unescape a JS string back to plain text. Free and in-browser.

Runs in your browser. Nothing is uploaded.

About JavaScript String Escape

Turning arbitrary text into a JavaScript string literal means escaping backslashes, the quote character you're using, line breaks and control characters. Choose double quotes, single quotes or a template literal and the escaper handles exactly the characters that style needs (template literals also escape ` and ${).

Unescape goes the other way, decoding \n, \t, \x41, \u00e9 and \u{1F600} sequences into real characters, which helps when reading minified bundles or log output.

How to use JavaScript String Escape

  1. Type or paste your text into the input box. Press Sample to see an example.
  2. Adjust the options. The result updates as you type.
  3. Copy the result, or press Use as input to chain another transformation.

Frequently asked questions

Why are U+2028 and U+2029 escaped?

These line and paragraph separators were illegal inside string literals before ES2019 and can still break older tools, so they're always escaped.

Is this the same as JSON escaping?

Close, but JSON only allows double quotes and doesn't support \x or \v escapes. Use JSON String Escape for JSON.

Is JavaScript String Escape free and private?

Yes. JavaScript String Escape is completely free with no sign-up. Everything runs in your browser, so whatever you type or paste never leaves your device.

See all developer tools →