JSON string escape / unescape

Escape text so it is valid inside a JSON string, or decode escaped JSON text back to what it says — with exact error positions.

Text
Escaped

Output will appear here

What this tool does

A JSON string cannot contain a raw double quote, a raw backslash, or a raw line break — the format needs those characters to mark where strings begin and end. So they are written as escape sequences instead, and this tool converts between the two forms. Paste ordinary text and get the escaped version ready to drop into JSON; switch direction and escaped text becomes readable again.

The second direction is the one people usually arrive for: a log line, an error message or a curl response that came back looking like a wall of backslashes. Everything runs in your browser, which matters when the payload you are trying to read is a production response.

The escape sequences

JSON defines a short list of escapes, and the tool uses exactly that list — nothing more exotic, because anything else is not valid JSON.

  • \" — a double quote, which would otherwise end the string.
  • \\ — a single backslash. This is why Windows paths and regex patterns double up.
  • \n and \r — newline and carriage return.
  • \t — tab. \b and \f exist too, for backspace and form feed.
  • \/ — an optional escape for the forward slash. Valid, never required; this tool accepts it and never produces it.
  • \uXXXX — any character by its hexadecimal code, which is how control characters and anything outside ASCII can be written.

Control characters — anything below code 32 — have no literal form inside a JSON string at all, so they always come out as \uXXXX escapes even when you have not asked for ASCII output.

Why backslashes multiply

The most common reason to reach for a tool like this is text that has been escaped more than once. Each round of encoding escapes the backslashes introduced by the round before it, so a single quote character grows a longer and longer tail:

original    He said "hi"
escaped     He said \"hi\"
escaped x2  He said \\\"hi\\\"

This happens when a value is serialised into JSON, that JSON is stored as a string inside another JSON document, and the result is logged. Decoding once undoes one layer; run it again on the result until the text reads normally. If you decode and the output still has stray backslashes, that is a genuine extra layer, not a bug in the conversion.

Quotes: value or fragment

A complete JSON string value includes the surrounding double quotes. But most of the time you are pasting into a string that already exists in your code or config, where those quotes would be wrong. So escaping produces the bare escaped content by default, and the "include surrounding quotes" option adds them when you want a value you can paste whole.

Decoding needs no such choice — it accepts both forms. Paste a fragment or paste a full quoted value straight out of a JSON document, and the surrounding quotes are recognised and stripped.

Unicode, and when to escape it

JSON is a Unicode format. "שלום" and "😀" are perfectly valid JSON strings exactly as written, and leaving them readable is the default here. The \uXXXX option exists for the systems that have not caught up: older log pipelines, terminals and parsers that assume ASCII and mangle anything else.

One detail matters when that option is on. Characters outside the basic range — most emoji — are stored internally as two units called a surrogate pair, and the format requires both halves to be written as separate escapes. An emoji therefore becomes two \u escapes rather than one longer one. Tools that get this wrong produce escapes that no parser accepts, which is the usual explanation for emoji that survive one system and break in the next.

When decoding fails

Not every backslash sequence is a valid escape. \q means nothing in JSON, and \u12 is a \u escape missing half its digits. Rather than passing those through unchanged and handing back output that looks fine but is not what your data said, the tool stops and reports the exact line and column where the bad sequence starts.

In practice that error is informative: a stray \q usually means the text was never JSON-escaped in the first place, and a truncated \u usually means the input was cut short — a log line clipped at a length limit, or a copy that stopped mid-sequence.

Frequently asked questions

Why does my text have \\" everywhere?
It was escaped more than once. Each pass escapes the previous pass's backslashes, so one original quote can end up preceded by several. Decode repeatedly — each run removes exactly one layer — until the text reads normally.
Should I turn on the surrounding quotes?
Only if you want a complete JSON value to paste as-is, for example as the whole right-hand side of a key. If you are pasting into a string that already exists in your code, leave it off — otherwise you will end up with quotes inside quotes.
Do Hebrew, Arabic, Chinese or emoji need escaping?
No. JSON strings are Unicode, so those characters are valid as they are and stay readable by default. Turn on the \uXXXX option only when a downstream system insists on plain ASCII; emoji are then written as their two required surrogate escapes.
What does "invalid escape sequence" mean?
The input contains a backslash followed by something JSON does not define, such as \q, or a \u without four hex digits after it. The position is reported so you can look at that spot: usually the text was not JSON-escaped to begin with, or it was truncated part-way through.
Is my text sent anywhere?
No. Escaping and decoding both run entirely in your browser, so tokens, payloads and log lines never leave your device.