PrettifyPrettify

JSON Unescape

Paste an escaped JSON string, such as a value copied from a log or a message queue, and get the formatted JSON document it holds. Prettify reads a full string literal in quotes and escaped JSON without its outer quotes. Text escaped more than once is unescaped until it is JSON.

Result
The unescaped JSON shows here as you paste.
Runs in your browser. Nothing is uploaded.

Escaped JSON in the wild

Logging libraries, queues, and APIs often store a JSON document as a string. When you copy that value, you get text full of \" and \n that a JSON parser reads as one long string, or rejects. Unescaping removes the escaping and shows the document, formatted and ready to read.

Some systems escape the same value twice, for example a log line that holds a message that holds a payload. Prettify keeps unescaping, up to three times, until it reaches a JSON object or array.

Key features

The tool accepts escaped JSON in the two forms that you usually find.

  • A JSON string literal in double quotes, such as "{\"a\":1}".
  • Escaped JSON without the outer quotes, such as {\"a\":1}, as many logs print it.
  • Text escaped twice or three times.
  • Numbers keep the digits they had in the string, so 64-bit IDs stay exact.
  • The result is formatted with your JSON indent and opens in the Tree view of the editor.

How to unescape JSON

Unescape in the box on this page, or paste the text straight into the editor. The box takes text up to 512 KB.

  1. Paste the escaped text into the box labeled "Paste escaped JSON", or select "Try an example".
  2. Read the formatted JSON in the result panel. The summary starts with "Unescaped".
  3. Select Copy or Download to keep the result.
  4. Select "Open in full editor" to browse the document in the Tree view.
  5. If the text is not escaped JSON, the panel says so. Check that you copied the whole value, from the first brace to the last.

Worked example: a log line

A service logged an order as a string. The first block is the text copied from the log, and the second is the result from the box.

The document has three keys and two levels. The total keeps its trailing zero, 19.90, because Prettify writes the number as it was in the string.

{\"level\":\"error\",\"order\":{\"id\":\"A-1001\",\"total\":19.90},\"retry\":true}

{
  "level": "error",
  "order": {
    "id": "A-1001",
    "total": 19.90
  },
  "retry": true
}

Unescape in the editor

The editor unescapes on its own. When you paste or open escaped JSON, the document opens as the JSON it holds, and the message after loading says "The text was escaped JSON, so it opened unescaped." Format detection also reads escaped JSON as JSON, not as YAML or text.

A document that holds a string with JSON in it, for example after a jq query, can be opened with Unescape JSON String in the command palette. History documents always open as they were saved.

Common uses

Escaped JSON turns up wherever one system passes JSON to another as text.

  • Read a payload from an application log or a CloudWatch or Datadog log line.
  • Inspect a message body copied from a queue such as SQS or Kafka.
  • Read a JSON value that an API returns inside a string field.
  • Check a fixture that a test stores as a string literal.

Limits to know

The unescaped text must be a JSON object or array. A string that holds a single number, a word, or plain text is not a document, so the tool reports that the text is not escaped JSON.

A JSON string cannot hold a raw line break. If a log wrapped a long line, or a copy added line breaks, join the lines again before you paste. The tool unescapes up to three levels; text escaped more often than that is rare and is left as it is.

Frequently asked questions

What input does the tool accept?

A JSON string literal in double quotes, or escaped JSON without the outer quotes. In both cases the unescaped text must be a JSON object or array, not a single number or word.

Is the text I paste uploaded?

No. Unescaping and formatting run in your browser, so log lines with tokens or personal data stay on your device.

Are large numbers kept exactly?

Yes. The numbers in the unescaped document keep the digits they had in the string, so 64-bit IDs and prices with trailing zeros do not change.

Why does the tool say my text is not escaped JSON?

The text has an unescaped quote, a raw line break inside a string, or it is cut off. Copy the whole value again, from the first brace or quote to the last.

How do I escape JSON again?

Use the JSON Escape tool, or run Copy as JSON String from the command palette in the editor, which copies the open document as one escaped string.

Is JSON unescaping free?

Yes. Unescaping on this page, and the automatic unescape when you paste into the editor, are free, with no account and no limit on use.

Related tools