JavaScript Escape / Unescape
Escape any text into a safe JavaScript string literal, or unescape a JS string back to plain text — all in your browser.
Last updated: May 30, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is JavaScript Escape / Unescape?
JavaScript Escape / Unescape converts text to and from the escaped form required inside JavaScript string literals. When you paste raw text, the tool adds the backslash sequences that JavaScript needs — \\ for a literal backslash, \" for a double-quote, \n for a newline, \r for a carriage return, and \t for a tab — so the result can be pasted straight into JS source code. Unescape reverses the process, decoding \\n, \\t, \\uXXXX and other sequences back to the original characters.
Everything runs locally in your browser, so code and secrets never leave your machine.
How to Use JavaScript Escape / Unescape
Paste your text into the input box
Choose Escape to build a JS string literal, or Unescape to decode one
Optionally enable \uXXXX escaping for non-ASCII characters
Copy the output into your JavaScript source code
Common Use Cases
- Embedding a multi-line user message into a JavaScript string safely.
- Escaping a Windows file path (backslashes) for use in a JS string.
- Decoding an escaped JavaScript string from a log file or API response.
- Escaping user input before building a dynamic script tag or eval expression.
- Converting non-ASCII characters to \uXXXX for ASCII-only JavaScript source.
Example Input and Output
Escape a Windows path and a message with special characters for a JavaScript string literal.
C:\temp\log.txt
Line "two" TabbedC:\\temp\\log.txt\nLine \"two\"\tTabbedHow This Tool Works
The tool scans your text character by character, replacing special characters with their JavaScript escape sequences (or reversing that mapping when unescaping), entirely in the browser using the shared code-escape engine.
Technical Stack
JavaScript string escapes
JavaScript string literals support \\, \" and \', \n, \r, \t, \b, \f, \uXXXX, and \xXX (hex escape). In template literals (backticks), only \` and \${ need special treatment.
Privacy
Processing is fully client-side — nothing is sent to a server.

