Single vs double quotes — which is the default?
JavaScript treats single-quoted ('...') and double-quoted ("...") strings identically — both interpret backslash sequences. The only difference is which delimiter you must escape: \' inside single-quoted, \" inside double-quoted. The tool escapes both so the output is safe in either context. Style guides like Airbnb and StandardJS prefer single quotes; Prettier defaults to double quotes — pick one and stick with it.
Does it produce template-literal-safe output?
Not directly. Template literals (backtick `...`) require escaping the backtick (\`) and the dollar-brace sequence (${). The output of this tool is safe for traditional quoted strings; for template literals you would additionally escape any literal backtick or ${ sequences. Most code generators avoid template literals as output targets for that reason.
Should I escape forward slashes?
No — JavaScript string literals do not require escaping the forward slash. The only place / has meaning is at the boundary of a regex literal. Some teams escape \/ inside strings purely so the literal can be safely embedded in an HTML <script> tag (where </script> would close the script). For non-HTML contexts, leaving / unescaped is correct.
Why is the backslash escaped first?
If quote escaping ran first, the new \" would itself contain a backslash that the next pass would re-escape into \\". Doubling backslashes first guarantees no character is double-encoded — the same ordering that JSON, Java, and .NET escape tools use.
Does it support the new \u{...} unicode escape?
No — it passes Unicode characters through unchanged, which is correct for JavaScript files served as UTF-8 (the modern default). If you need ASCII-only source for legacy targets, use \u{NNNNN} for code points above 0xFFFF and \uNNNN for BMP characters. JS source files in 2024+ rarely need that.
Is the output safe inside a <script> tag in HTML?
Almost. The five string-literal escapes are correct, but a literal </script> sequence inside a JS string still terminates the surrounding HTML script tag — a classic XSS vector. To be safe inside an inline script, additionally replace < with \x3C (or escape the / in </). For external .js files served with the right MIME type, this is not an issue.
How does it compare with JSON.stringify?
JSON.stringify wraps the output in double quotes and additionally escapes all control characters below U+0020 as \u00xx, plus surrogate pairs and the line separator (U+2028 / U+2029). It produces strict JSON, not arbitrary JS. This tool produces JS-flavoured output — safe for either single or double quotes — and trusts the surrounding context for control-character handling.
Is the input sent to a server?
No. The escape transformation runs entirely in JavaScript inside your browser. JS source often contains config tokens, secrets, or proprietary algorithms — none of it leaves your device. Verify in DevTools Network tab.