Turn an escaped string back into JSON
This string to JSON converter reverses stringification. When a JSON document has been stored or logged as a string, you see it full of \" and \n sequences and it is almost impossible to read. Paste that string here and the tool removes the escaping, parses the JSON inside and shows it formatted with your chosen indent.
It is built for the forms such strings actually take in the wild, not only for perfectly quoted literals.
Inputs it understands
A quoted JSON string literal
The classic case, as returned by JSON.stringify or found inside another JSON document:
"{\"user\":{\"id\":7,\"name\":\"Sara\"},\"expires\":3600}"
Escaped text without outer quotes
Log lines and database exports often drop the surrounding quotes. The tool detects the escape sequences and decodes them anyway:
{\"event\":\"login\",\"user\":\"ana\",\"ok\":true}
Result:
{
"event": "login",
"user": "ana",
"ok": true
}
Single-quoted literals
Strings copied from JavaScript, Python or PHP source often use single quotes, with apostrophes escaped as \'. Input like '{"name":"O\'Neil"}' is converted to a double-quoted literal first and then decoded, so the name comes out as O'Neil.
Double- and triple-encoded JSON
When a value has been stringified twice, decoding once only gives you another string. The converter keeps unwrapping while the result is still a string that looks like JSON, up to five extra layers, so this input:
"\"{\\\"sku\\\":\\\"A-1\\\",\\\"qty\\\":2}\""
still ends as a plain object with sku and qty keys. If the input is already normal JSON, it is simply formatted.
Where escaped JSON comes from
- Application logs that serialize the request body into a message field.
- Database columns of type text or varchar that store a JSON document, exported to CSV or copied from a query tool.
- Message queues and webhooks whose envelope carries the real payload as a string property.
- Environment variables and CI secrets that hold a JSON config.
Limits and common errors
- Only the top level is decoded. If you paste
{"payload":"{\"a\":1}"}, the outer object is valid JSON, so it is formatted andpayloadstays a string. Copy that field's value and convert it on its own. - The decoded text must be JSON. A string such as
"not json"decodes to plain words and is reported as an error at line 1, column 1. - Errors point into the decoded JSON. A trailing comma or a Python
Trueinside the string is reported with a line and column of the unescaped document, not of your input. - Broken escaping. If a quote inside the string was never escaped, the literal ends early and decoding fails. Try the JSON fixer on the unescaped text.
String to JSON vs related tools
Use JSON Stringify for the opposite direction. When you need to remove escaping from any text, not just JSON, the JSON unescape tool returns plain text instead of parsed data. After decoding, the JSON viewer is handy for exploring a large payload as a tree.
Privacy
Decoding runs in your browser, which matters when the string comes from production logs. Nothing is uploaded unless you use Load URL (fetched through our server) or Save & Share (stored to create a link).
Convert a string to JSON in Python
json.loads() parses a string that contains JSON and returns a dictionary or list. If the result is still a str, the text was encoded twice, which is common for values pulled from logs, message queues and database columns; run json.loads() again on that result. A string with single quotes, True or None is a printed Python dictionary rather than JSON, and json.loads() rejects it; parse it with ast.literal_eval() instead. Do not use eval() for this, because it runs whatever code the string contains.
import ast
import json
text = '{"user": {"id": 7, "name": "Sara"}, "expires": 3600}'
data = json.loads(text) # str -> dict
print(data["user"]["name"]) # Sara
# A string that was encoded twice needs two passes
escaped = '"{\\"user\\":{\\"id\\":7,\\"name\\":\\"Sara\\"},\\"expires\\":3600}"'
once = json.loads(escaped)
print(type(once).__name__) # str
print(json.loads(once)["expires"]) # 3600
# A printed Python dict is not JSON: single quotes, True, None
printed = "{'id': 7, 'active': True, 'manager': None}"
print(json.dumps(ast.literal_eval(printed)))
# {"id": 7, "active": true, "manager": null}
To see what an escaped string decodes to before writing any code, paste it above: the page unwraps it and shows the formatted JSON.