Free JavaScript escape & unescape tool — quotes, backslashes, newlines for JS string literals

Escaping runs entirely in your browser — nothing is uploaded.

JavaScript Escape & Unescape — safe JS string literals

Embedding arbitrary text in JavaScript source means escaping the characters that would otherwise terminate the string or start an interpolation. Unlike JSON, JavaScript has three string forms — single quotes, double quotes and backtick template literals — each with its own quote to escape. This tool escapes for all of them, and reverses the process, entirely in your browser.

What gets escaped

CharacterEscaped as
Backslash \\\ (escaped first)
Quotes ' " `\' \" \`
Newline / return / tab\n / \r / \t

Template-literal gotcha

In backtick strings the sequence $${} begins interpolation. If your text contains a literal $ followed by {, escape the backtick form or switch to a quoted string — otherwise the runtime tries to evaluate the contents as an expression.

Related escape tools