About this tool
Escape turns any text into a JavaScript string literal you can paste into code: quotes, backslashes, line breaks and control characters become escape sequences. Unescape does the reverse, decoding a literal (with or without its quotes) back into the text it represents.
Escape sequences
\nline feed,\rcarriage return,\ttab,\b,\f,\vand\0.\',\"and\\for quotes and backslashes; in template literals also\`and\${.\xHHfor a byte-sized code point,\uHHHHfor any UTF-16 code unit and\u{1F600}for any code point.
Escape non-ASCII writes every character outside ASCII as \u escapes, for files that must stay pure ASCII. Safe inside <script> also escapes </script and <!--, so a string embedded in an inline script can’t end the script element early. For JSON strings, use the JSON Escape tool, which follows JSON’s stricter rules.
FAQ
How do I escape a string in JavaScript?
Paste the text with Escape selected. Quotes, backslashes and line breaks are converted into escape sequences and the result is wrapped in your chosen quotes.
How is this different from JSON escaping?
JSON allows only double quotes and fewer escapes. JavaScript also supports single quotes, template literals, \x and \u{…} escapes.
Why escape </script>?
Inside an inline <script>, the HTML parser ends the script at </script even inside a string. Writing <\/script avoids that.
Can it unescape a string without quotes?
Yes. Quotes around the input are optional; they’re removed when present.
Is my text uploaded?
No. Everything runs in your browser.