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
- Paste the encoded payload, including its outer quotes if it has them.
- Tick URL decode first when the value came out of a query string or a form post.
- Leave Decode JSON nested inside strings on to unwrap documents stored inside a string field.
- 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.