JavaScript Escape / Unescape
runs in your browserno sign-upfree
Escape text for a JavaScript string (quotes, backslashes, line breaks) or unescape it back.
Escaped
About this tool
This tool escapes text so it can be pasted inside a JavaScript string: backslashes, the quote you use, line breaks, tabs and other control characters become \\ \' \n \t and so on. Unescape does the reverse and understands every JavaScript escape, including \xHH, \uXXXX and \u{…}.
How to use
- Choose Escape or Unescape.
- For Escape, pick the quote style you will use: single, double or a template literal (backticks).
- Paste your text. The result appears straight away; copy it into your code.
FAQ
Why does the quote style matter?
Only the quote that surrounds the string needs escaping: in 'single quotes' an apostrophe becomes \', in "double quotes" a " becomes \". In template literals the backtick and ${ are escaped instead.
What does "ASCII only" do?
It writes every non-ASCII character as an escape (é becomes \u00E9, emoji become \u{…}), so the code is safe in files or systems that do not handle UTF-8 well.
How do I use Swap?
Swap moves the result into the input box and switches between Escape and Unescape, so you can check the round trip.
Is my text uploaded?
No. Escaping runs entirely in your browser, so your text never leaves your device.