JavaScript Escape & Unescape

Escape strings for safe embedding in JavaScript source.

About the JavaScript Escape & Unescape

Escape a string so it can be embedded safely inside JavaScript single-quoted, double-quoted, or template literals, or unescape \n, \t, \uXXXX sequences back to characters.

Frequently asked questions

Why not just paste the text into my code?

Unescaped quotes and backslashes change string boundaries or create invalid syntax; escaping makes the literal safe and exact.

Does it handle Unicode?

Yes — non-ASCII characters can be emitted as \uXXXX escapes for maximum portability.

Related tools