Developer guide
Convert a JSON string into readable JSON
A JSON string can contain another JSON value as text. To inspect it, decode the string first, then format the inner value.
The problem
This comes up when APIs return serialized JSON inside a field, or when logs store request bodies as strings.
Example
{
"body": "{\"ok\":true,\"items\":[1,2,3]}"
}
{
"ok": true,
"items": [
1,
2,
3
]
}
How to fix it
- Find the string field that contains the encoded JSON.
- Copy only the string value, including its escape sequences, and decode it as JSON.
- Format the decoded result so arrays and objects are easier to scan.
Outer JSON and inner JSON
A payload can be valid JSON even when one field contains another JSON document as a string. The outer parse only proves that the wrapper is valid.
After you copy the string field, decode it separately and format the decoded value. That second step is where the nested structure becomes readable.
Common mistakes
- Copying the field name along with the string value
- Dropping a quote or backslash while selecting text
- Trying to parse a partial string
- Forgetting that the outer object may be valid while the inner string still needs inspection
Related problems
FAQ
Why would an API return JSON as a string?
Some systems store or forward request bodies as text, especially in logs, queues, and audit records.
Do I need to remove every backslash by hand?
No. Let a JSON parser decode the string layer so escape sequences are handled correctly.
Can the inner string contain invalid JSON?
Yes. The outer JSON can be valid even when a string field contains text that is not valid JSON.