How to use JavaScript Escape
- Paste or type the text you want to escape.
- Adjust the options if you need to.
- Copy the escaped result.
About JavaScript Escape
A JavaScript string literal cannot contain a raw line break or an unescaped quote of its own kind. If you build a string from user input or paste a block of text into code, the quotes and backslashes have to be escaped, otherwise the script stops with a syntax error, or worse, runs something you did not intend.
The tool escapes backslashes, both kinds of quotes, line breaks, tabs and other control characters, so the result is safe inside single or double quoted strings. Template literals are a different story: they need only backticks and ${ escaped.
What gets escaped
Backslash becomes \\, quotes become \" and \', a line break becomes \n, a tab \t, other control characters \xNN.