JavaScript Escape/Unescape
Turn text into a ready-to-paste JavaScript string literal, or decode escaped string contents back to text. Unicode-aware and safe: your input is never evaluated.
Encode and decode JavaScript string values
Handle quotes, slashes, line breaks and Unicode without running JavaScript.
Escape text wraps the result in your chosen quote style and encodes special characters such as quotes, backslashes, tabs, newlines and control characters. Unicode is kept readable by default; turn on the Unicode option to emit \u escapes for non-ASCII characters.
The result is a string literal value only. Add a variable assignment or other surrounding syntax yourself.
Unescape string decodes common JavaScript escapes, \xNN, \uNNNN, \u{...} and escaped line breaks. A quoted single- or double-quoted literal can be pasted as-is, or paste only its contents.
This is not a full JavaScript parser. It does not evaluate expressions, template literals, concatenation or assignments.
How to convert a JavaScript string
Choose a direction, add text, and copy the result.
Select Escape or Unescape
Escape creates a quoted literal; Unescape decodes a string value.
Enter your text
Choose single or double quotes for Escape. Unicode escapes are optional.
Copy or download
Review the result, then copy it into your JavaScript source.
Frequently asked questions
Escape wraps your text as a complete single- or double-quoted JavaScript string literal and encodes quotes, backslashes, line breaks and control characters.
It decodes common JavaScript string escapes, hexadecimal escapes, four-digit Unicode escapes, code-point Unicode escapes and escaped line breaks. Paste a quoted string literal or only its escaped contents.
No. It uses a string-processing routine in a worker. It never calls eval or Function and does not execute pasted code.
No. It decodes a string value only; it does not validate surrounding assignments, templates, expressions or source code.
No. Processing happens locally in a time-limited browser worker. The page does not upload or store your input.
The maximum input size is 1 MiB. Automatic processing pauses on large input; click Run conversion to process it manually.