JSON Decode

Take JSON that arrived quoted, escaped or percent encoded and get the real indented document back.

Encoded JSON
Decoded data
Runs locally in your browser

About the JSON Decode

JSON rarely reaches you in the shape it left. A log line wraps the payload in quotes and doubles every backslash, a query string percent encodes it, and a message queue sometimes stores a whole document inside a single string field. This decoder undoes those wrappers in order: it optionally percent decodes the input, removes a surrounding pair of quotes, resolves the escape sequences, and then parses what remains.

With "Decode JSON nested inside strings" switched on it keeps going while the result is still a string that starts with a brace or a bracket, up to eight layers deep. That is what turns "{\"data\":\"{\\\"id\\\":7}\"}" into a normal two level object instead of an object holding a lump of text. Unicode escapes such as \u00e9 come back as ordinary characters, so accented names read normally again.

If the input decodes to plain text rather than to a structure, that text is shown as is, which matches how json_decode behaves in PHP when it is handed a quoted string. If nothing valid is left after unescaping, the parser reports the line and column where it gave up instead of returning a half decoded mess.

Going the other way is the job of JSON Encode, and if all you have is a code assignment such as const body = "...", start with JSON Unstringify.

How to use

  1. Paste the encoded payload, including its outer quotes if it has them.
  2. Tick URL decode first when the value came out of a query string or a form post.
  3. Leave Decode JSON nested inside strings on to unwrap documents stored inside a string field.
  4. Read the status line to see how many layers were peeled, then copy or download the result.

Common questions

What is the difference between decoding and formatting JSON?
Formatting only changes whitespace in text that is already valid JSON. Decoding first removes quoting and escaping so that there is valid JSON to work with at all.
Why does my decoded output show accented characters instead of \u sequences?
A \u escape is only a way of writing a character in transit. Once parsed, it becomes the character itself, which is what you want in a readable document.
How many layers of nesting can it unwrap?
Up to eight. That is far beyond anything a real pipeline produces, and the limit stops a pathological input from looping.
Can it decode a Base64 payload?
Not here. Run it through the Base64 decoder first, then paste the result into this tool.