devtools

Backslash Escape / Unescape

Escape text into a JSON or JavaScript double-quoted string literal and back. Handles newlines, tabs, quotes, backslashes and control characters, in-browser.

Runs entirely in your browser — your data never leaves your device.

How to use Backslash Escape / Unescape

What it does & when you need it

This tool escapes text so it can sit safely inside a double-quoted JSON or JavaScript string, and unescapes such a literal back into raw text. It is the fix for the everyday problem of pasting a multi-line log line, a Windows file path, or a snippet full of quotes into code or a JSON payload without breaking the surrounding string. Escape turns the dangerous characters into backslash sequences; unescape reads them back so you can see the real newlines, tabs, and quotes a literal stands for.

How to use

  1. Choose Escape or Unescape.
  2. Paste your text on the left, or press Sample to load an example.
  3. Read the result on the right, then copy it with Copy result or the Ctrl/Cmd + Enter shortcut.

Things worth knowing

What gets escaped. A backslash becomes \\ and a double quote becomes \". The common whitespace controls map to their short forms — \n, \r, \t, \b, \f — and any other character below U+0020 becomes a \uXXXX escape. Printable and non-ASCII characters, including emoji, pass through unchanged, so the output stays readable.

Unescaping is lenient. JSON is strict about which escapes it allows, but the decoder here also accepts JavaScript extras such as \xXX, a single-quote escape, and the \u{...} brace form. Anything it cannot decode — a dangling backslash, an incomplete \uXX, or an unknown letter after a backslash — is reported rather than guessed at.

Pick the right escaper for the job. This one is for string literals. To make non-English text ASCII-safe use Unicode Escape; for a URL query value use the URL Encoder; for markup use HTML Entities.

Examples

Escape a multi-line string

He said "hi".
Windows path: C:\logs	tab here

The real newline, tab, quote and backslash on the left become \n, \t, \" and \\ in the literal.

Unescape a JSON string

Line one\nLine two\tand \"quoted\" text

Switch to Unescape mode to turn the \n, \t and \" escapes back into a newline, tab and quotes.

Escape a Windows path

C:\Users\dev\config.json

Each single backslash doubles to \\ so the path survives inside a JSON string.

Frequently asked questions

What exactly does escaping produce?

It turns your text into the body of a double-quoted JSON or JavaScript string. Backslashes and double quotes are prefixed with a backslash, and the common whitespace controls become the short forms \n, \r and \t. Any other character below U+0020 becomes a \uXXXX escape, so the result is safe to paste between quotes.

How is this different from URL or HTML escaping?

Each scheme targets a different destination. This one produces a JSON or JavaScript string literal, so it escapes quotes, backslashes, and control characters. URL encoding percent-escapes bytes for a query string, and HTML entity encoding protects <, > and & for markup. Pick the one that matches where the text will be pasted.

Does the escaped output work in both JSON and JavaScript?

Yes for the characters this tool emits — \n, \r, \t, \b, \f, an escaped quote, a doubled backslash and \uXXXX are all valid in both. The reverse is not always true: JSON is stricter and rejects a few escapes JavaScript allows, such as \xXX, so the unescaper here accepts those extras for convenience.

What happens with an invalid escape when unescaping?

The unescaper decodes recognised sequences and reports a clear error on anything it cannot — a dangling backslash at the end of the input, an incomplete \uXX, or an unknown letter after a backslash. That way a malformed literal is flagged rather than silently turned into the wrong text.

Is my text sent anywhere?

No. Escaping and unescaping run entirely in your browser, so code, log lines, or config values never leave your machine, and the tool works offline once the page has loaded.