What this tool does
It turns arbitrary text into something you can paste between quotes in JavaScript or TypeScript without breaking the literal:
- backslashes are doubled, so
C:\pathstays a path and does not become an escape sequence; ',"and`are all escaped, so the result is valid in any of the three quote styles;- newline, carriage return, tab, backspace, form feed and vertical tab get their named forms —
\n,\r,\t,\b,\f,\v; - any other character below U+0020 becomes
\uXXXX. NUL is one of them: it comes out as the escaped U+0000 form, not as a named sequence. Above ASCII there are exactly two exceptions: U+2028 and U+2029, the Unicode line separators. Raw in a literal they were a syntax error before ES2019 and still break one embedded in a<script>tag, so they come out as\u2028and\u2029.
Characters above ASCII are deliberately left alone. JavaScript files are UTF-8, and "café" is both valid and readable — escaping it to "caf\u00e9" would only make the literal harder to read.
When you need it
Embedding a snippet, a regex fragment, a log line or a chunk of JSON into a .js or .ts file by hand. Also useful for JSON.parse payloads written inline, where an unescaped quote silently truncates the string.
What it does not do
It escapes for a string literal, not for a template placeholder. If your output lands inside `...${x}...`, the ${ sequence is still interpreted — this tool escapes the backtick but does not neutralise interpolation.
Private by design
Everything runs locally in your browser with JavaScript. Your data is never uploaded, which makes the tool safe for sensitive content, and it keeps working offline.