WebToolsPlanet
Developer Tools

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.

JavaScriptEscapeUnescapeBrowser based

Last updated: May 30, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What 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

1

Paste your text into the input box

2

Choose Escape to build a JS string literal, or Unescape to decode one

3

Optionally enable \uXXXX escaping for non-ASCII characters

4

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.

Raw text
C:\temp\log.txt
Line "two"	Tabbed
Escaped JavaScript
C:\\temp\\log.txt\nLine \"two\"\tTabbed

How 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

TypeScriptJavaScript string-literal rulesClient-side processing

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.

Frequently Asked Questions

Which characters does it escape?
Escaping emits \\ \" \n \r \t \b \f and optionally \uXXXX for non-ASCII code points. Unescaping also handles \' and any \uXXXX sequences.
Does it handle template literals (backticks)?
No. Template literals have their own rules (backtick and ${ need escaping). This tool targets standard double-quoted or single-quoted JS string literals.
Is my input sent to a server?
No. All escaping and unescaping runs entirely in your browser using JavaScript string operations.
What is the difference between this and the String Escape tool?
The String Escape tool supports multiple formats (JSON, HTML, URL, JavaScript). This page is a focused, JavaScript-only experience with a cleaner interface and more specific examples and documentation.