Developer guide
Format escaped JSON from logs
Escaped JSON is JSON stored inside a string, often with backslashes before quotes and newline characters.
The problem
You may see this in log lines, database fields, webhook payloads, or error messages that wrap JSON inside another string.
Example
"{\"event\":\"login\",\"user\":{\"id\":42,\"role\":\"admin\"}}"
{
"event": "login",
"user": {
"id": 42,
"role": "admin"
}
}
How to fix it
- First identify whether the whole value is a JSON string. It often starts and ends with a quote.
- Decode the outer string to remove escaped quotes, then format the inner JSON object.
- If the value is double-escaped, you may need to decode one layer at a time.
How to spot escaped JSON
Escaped JSON usually has many backslashes before quotes, such as \"name\" instead of "name". That means you are looking at JSON stored as text inside another value.
The safest approach is to decode one layer, inspect the result, and stop when you have the object or array you need to read.
Common mistakes
- Formatting the escaped string without decoding the outer layer
- Removing backslashes manually and breaking valid characters
- Confusing JSON inside a string with a normal JSON object
- Copying only part of a log line
Related problems
FAQ
Why are there backslashes before every quote?
The quotes are escaped because the JSON object is being stored as text inside another string.
Can I paste escaped JSON into the formatter directly?
If it is a valid JSON string, the parser can read it. Then copy the decoded inner value and format that.
Is escaped JSON invalid?
Not necessarily. It can be valid as a string, but it is not yet the object you probably want to inspect.