JavaScript String Escape
Escape text for a JavaScript string literal in single, double or backtick quotes, including \x, \u and U+2028 handling.
Runs in your browserText → JavaScript string
Loading tool…
Example
It's "ok" next
It\'s "ok"\nnext
How to use the JavaScript String Escape
- Paste or type your Text into the input area, or open a file from your device.
- Adjust the options above the editor if the tool offers any.
- Review the JavaScript string result, then copy it or download it as a file.
Privacy and limitations
- Your data is processed on your device and is not uploaded to any server.
Related converters
JSON String EscapeEscape text for use inside a JSON string: quotes, backslashes, newlines and control characters, optionally ASCII-only.Unicode EscapeEscape non-ASCII characters as \uXXXX, \u{…}, \U0001F600 or U+ code points for source code and JSON.JavaScript String UnescapeDecode JavaScript escape sequences such as \n, \x41, \u00e9, \u{1F600} and legacy octal escapes into plain text.JSON String UnescapeTurn an escaped JSON string (with or without surrounding quotes) back into plain text, reporting invalid escapes.XML EscapeEscape the five XML special characters (& < > " ') so text is safe in XML element content and attributes.XML UnescapeDecode XML entities (& < > " ') and numeric character references back to plain text.HTML EscapeEscape & < > " and ' so untrusted text can be safely inserted into HTML pages and attributes.HTML UnescapeConvert escaped HTML (<p>, &, ©, €) back to the original characters and markup.