JSON Unescape and Escape

Paste an escaped JSON string and get readable, formatted JSON back, even when it was escaped twice. Or escape JSON to put it inside a string.

I want to:
0 characters

Frequently asked questions

What does it mean to unescape JSON?

It turns a JSON string back into the JSON it holds: \" becomes a quote, \\ a backslash and \n a line break. You need it when JSON was stored or logged as text, so it shows up as one long line full of backslashes instead of something you can read.

Why does my JSON have so many backslashes?

Because it was escaped more than once. Each time JSON is saved as a string, every quote gets a backslash, and the next time those backslashes get one too, so \" turns into \\\". This tool takes off every layer in one go and says how many there were.

How do I convert a JSON string to a JSON object?

Paste it here and the object comes out formatted. In code, parse it: JSON.parse(s) in JavaScript, json.loads(s) in Python, json_decode($s, true) in PHP. If the result is still a string rather than an object, it was escaped twice, so parse it once more.

What if my JSON has escaped JSON inside one of its fields?

That is common in SQS and SNS messages, API Gateway events and webhooks: the outer JSON is fine, but one value, often called body or Message, is JSON saved as text. Paste the whole thing, and the line under the result says how many values hold JSON. Click Unescape those too, and they become JSON in place, also when one sits inside another. They stay text until you click, because it turns that value from a string into an object.

Why does it say my JSON is not valid?

The message says what is wrong and gives the line and column. The usual causes are a comma after the last item, single quotes instead of double, keys without quotes, True, False or None from Python instead of true, false and null, and a log line that was cut off before the JSON ended.

Does it change my numbers or the order of the keys?

No. Numbers are copied exactly as written, so a long id is not rounded the way JSON.parse rounds it in a browser, and the keys stay in their order, duplicates included. Only the spacing changes, and escapes such as \u00e6 are shown as the character they stand for (æ). Characters that have to stay escaped, like a line break inside a string, stay escaped.

What is the difference between JSON escape and JSON.stringify?

None, here. Escape JSON gives exactly what JSON.stringify() returns for your JSON as text: the JSON wrapped in quotes with its own quotes and backslashes escaped. Tick Leave out the outer quotes to drop the outer pair. For other kinds of strings, such as SQL, CSV or a JavaScript string in single quotes, use Escape Text.

Is my JSON sent anywhere?

No. It is unescaped and escaped in your browser, so logs and API responses with private data stay on your computer.