Beautify Escaped JSON — Unescape Backslashes and Format at Once
Table of Contents
You've encountered JSON that looks like this: "{"name":"Alice","age":30,"roles":["admin","editor"]}" — where the entire JSON is itself a string, wrapped in quotes, with every internal quote escaped with a backslash. This is escaped JSON, and it's extremely common in logging systems, message queues, and APIs that serialize JSON inside JSON.
Here's how to unescape and format it.
What Is Escaped JSON and Why Does It Happen?
Escaped JSON is a JSON string that contains another JSON document as its value. When a system serializes a JSON object, then wraps it in another JSON string, every quote character in the inner JSON must be escaped with a backslash to avoid breaking the outer string.
It happens most often in these situations:
- Log files: Logging systems often serialize the full event payload as a string field:
{"level":"error","message":"Request failed","payload":"{"user":"alice","status":500}"} - Message queues (Kafka, RabbitMQ, SQS): Messages are often JSON-encoded strings, then placed in a JSON envelope — double-serialized
- Database columns: Some databases store JSON as a text column, and when that column value is included in a JSON response, it gets serialized as a string
- API responses with embedded JSON: Some APIs return dynamic data as a JSON string value rather than a native JSON object
How to Unescape and Beautify Escaped JSON
Method 1: Use the formatter (handles some escaped JSON automatically)
Paste the escaped JSON string into the WildandFree JSON Formatter. If the JSON is a string value (the whole thing is wrapped in outer quotes), the formatter will parse it and show the escaped content. Copy the content, remove the outer quotes and unescape manually, then format the result.
Method 2: JavaScript one-liner (fastest for developers)
If you have access to a browser console (F12 in Chrome), paste this:
console.log(JSON.stringify(JSON.parse(JSON.parse(yourEscapedString)), null, 2))
Or for a double-serialized string: console.log(JSON.parse(yourEscapedString)) then copy the result and paste into the formatter.
Method 3: Python
import json
inner = json.loads(escaped_string)
print(json.dumps(inner, indent=2))
Recognizing Common Patterns of Escaped JSON
Single-escaped (one level):
The outer quotes are part of the string value, inner quotes are ". Example:
"{"name":"Alice"}"
One JSON.parse() or json.loads() call turns this back into an object.
Double-escaped (two levels):
Inner quotes are \" (two characters). Example:
"{\"name\":\"Alice\"}"
Two JSON.parse() calls, or one json.loads() followed by another on the result.
Embedded in a larger JSON response:
{"status":"ok","data":"{"user":"alice","id":123}"}
Parse the outer JSON, then parse the data field separately.
The easiest debugging approach: paste the whole thing into the formatter, see what it tells you, then work from there.
Preventing Double-Serialized JSON in Your Own Code
If you're building a system that produces escaped JSON, the fix is usually straightforward: serialize the inner object as a native JSON value, not as a string field.
Wrong pattern in JavaScript:
const response = { data: JSON.stringify(myObject) }; // creates escaped JSON
Right pattern:
const response = { data: myObject }; // native JSON object, no escaping
The wrong pattern happens when code serializes an object to a string, then puts that string into a JSON field that gets serialized again. Each layer of serialization adds a layer of escaping. The fix is to work with objects, not serialized strings, until the final JSON.stringify() at the output boundary.
Try It Free — No Signup Required
Runs 100% in your browser. No data is collected, stored, or sent anywhere.
Open Free JSON FormatterFrequently Asked Questions
How do I unescape JSON that has backslashes everywhere?
In JavaScript: JSON.parse(escapedString) removes one level of escaping. In Python: json.loads(escaped_string). If there are multiple levels, call parse/loads multiple times. Or paste into the browser console and use JSON.parse iteratively.
Why does my API return JSON as a string instead of an object?
Common causes: the server is double-serializing (running JSON.stringify on an already-serialized value), the value is stored as text in the database instead of as a JSON column, or the API is wrapping raw data in a string for historical reasons. Check the Content-Type header and the raw response to confirm.

