JSON Escape / Unescape

Turn JSON into a string literal and back.

Runs locallyYour input is processed in this tab. The editor blocks outgoing network requests.
JSON input

JSON Escape / Unescape turns JSON into a quoted string literal — with every quote and line break backslash-escaped — and turns a stringified value back into readable JSON. Use it for JSON stored inside another JSON field, a log line, an environment variable or source code. Everything runs in your browser; nothing is uploaded.

How to escape and unescape JSON

  1. Paste your JSON, or the escaped string you want to decode, into the input pane.
  2. Choose the mode: Escape (stringify) or Unescape (parse). For escaping, decide whether to Minify before escaping and whether to Wrap in quotes.
  3. Copy the result with ⌥/Alt C. Use the Unescape or Escape action to switch direction in place, or Format JSON to open unescaped JSON in the JSON Formatter.

Examples

Object to string literal

The default: minify, escape the inner quotes, wrap the whole value in double quotes. The result can be pasted as a string value inside another JSON document.

JSON
{"event":"signup","meta":{"plan":"pro"}}

Result:

Text
"{\"event\":\"signup\",\"meta\":{\"plan\":\"pro\"}}"

Keeping the original layout

With Minify before escaping off, the line breaks and indentation are kept as \n and spaces. Existing escapes are escaped a second time, so \" becomes \\\" and \t becomes \\t.

JSON
{
  "query": "SELECT * FROM t WHERE name = \"Zoë\"",
  "tab": "a\tb"
}

Result:

Text
"{\n  \"query\": \"SELECT * FROM t WHERE name = \\\"Zoë\\\"\",\n  \"tab\": \"a\\tb\"\n}"

Stringified JSON back to JSON

Unescape mode decodes the string literal and, because the decoded text is itself JSON, pretty-prints it.

Text
"{\"event\":\"signup\",\"meta\":{\"plan\":\"pro\"}}"

Result:

JSON
{
  "event": "signup",
  "meta": {
    "plan": "pro"
  }
}

A value encoded twice

Log pipelines sometimes stringify a payload that was already a string. Unescape removes every layer in one pass and reports "Removed 2 layers of string encoding."

Text
"\"{\\\"event\\\":\\\"signup\\\",\\\"plan\\\":\\\"pro\\\"}\""

Result:

JSON
{
  "event": "signup",
  "plan": "pro"
}

Options explained

  • Wrap in quotes — surrounds the escaped output with double quotes so it is a complete JSON string literal; turn it off to get only the escaped contents, for pasting between quotes you already have.
  • Minify before escaping — compacts valid JSON to a single line before escaping, which gives the shortest string; turn it off to preserve the exact text, including indentation and line breaks.

Common escaping problems

"Input is not valid JSON, so it was escaped as plain text"

With Minify before escaping on, the tool tries to parse the input first. If it is not valid JSON, the text is escaped exactly as it is. That is fine for plain text; if you expected JSON, check it in the JSON Validator.

"Not a valid JSON string literal (line 1, column 6)."

In Unescape mode, the input contains a backslash sequence JSON does not allow, such as \x or \', or an unescaped quote in the middle of the text. The line and column point at the problem; press F8 to jump there. Valid escapes are \", \\, \/, \b, \f, \n, \r, \t and \uXXXX. The input may have come from a language with different string rules.

"Removed N layers of string encoding."

The value was encoded more than once — a string inside a string. Unescape keeps decoding until the text is no longer a string literal, so one click returns the JSON, and the notice tells you how many layers there were.

Key order and long numbers

Minify before escaping parses the JSON and writes it back on one line, but keys stay in their original order and integers larger than 2^53, such as IDs, keep every digit. Only whitespace between tokens changes.

Output has no surrounding quotes

Wrap in quotes is off. Turn it on if you are pasting the result as a standalone value rather than between existing quotes.

FAQ

Is it safe to paste payloads containing secrets?

Yes. Escaping and unescaping happen in your browser inside an isolated frame that blocks network requests, so tokens and webhook payloads never leave your device, and nothing is stored on a server. Settings are remembered locally; the input is kept only if you turn on "Remember my last input".

What is stringified JSON?

It is JSON that has been turned into a string value, usually with JSON.stringify applied to text that was already JSON. You see it in log fields, message queue payloads, database text columns and webhook bodies, where it appears as a quoted string full of \". Unescape mode reverses it.

Is this the same as JSON.stringify?

Escape mode produces the same result as calling JSON.stringify on the JSON text: a double-quoted string with quotes, backslashes and control characters escaped. With Minify before escaping on, it is equivalent to JSON.stringify(JSON.stringify(value)), the usual way to embed one JSON document inside another.

Can I paste the contents without the outer quotes?

Yes. Unescape mode accepts both "{\"a\":1}" and {\"a\":1}; when the outer double quotes are missing, they are added before decoding. Single outer quotes, as copied from some shell scripts and logs, are recognised too, so '{"a":1}' decodes to the object inside.

Are non-ASCII characters escaped?

No. Characters such as é, ₹ or emoji are kept as they are, because JSON strings can contain any Unicode character. Only quotes, backslashes and control characters such as line breaks and tabs are escaped. If a system needs pure ASCII, use Escape non-ASCII in the JSON Formatter first.

How do I put JSON in a shell command or environment variable?

Escape it with Wrap in quotes off to get a single line with escaped inner quotes, then wrap it in the quoting your shell expects. In most shells, single quotes around unescaped minified JSON also work, so the JSON Minifier alone is often enough.

Escape vs unescape at a glance

Escape takes a structure and produces text: object in, string literal out. Unescape takes a string literal and returns the text inside it, pretty-printed when that text is JSON. When the value was encoded more than once, every layer is removed in the same pass.

Browse all Data Formatters & Converters