Tool Kumar tool
JSON escape and unescape
Paste JSON to get it as one escaped string, the form you need when JSON travels inside another JSON value, an environment variable or a test fixture. Paste an escaped string to turn it back into readable JSON.
How to use this tool
- Paste a JSON document or open a file.
- Read the escaped string in the Format view, where String is selected. Pretty and Minify show the document itself.
- To unescape, paste a JSON string that contains JSON, then choose Unescape JSON in the banner. The input becomes the formatted document.
Worked example
The document is minified, then written as one JSON string: every inner quote becomes \" and the escaped line break in the note becomes \\n.
Input
{"event":"signup","user":{"name":"Ada","email":"ada@example.com"},"note":"Line one\nLine two","quote":"She said \"hi\""}Output
"{\"event\":\"signup\",\"user\":{\"name\":\"Ada\",\"email\":\"ada@example.com\"},\"note\":\"Line one\\nLine two\",\"quote\":\"She said \\\"hi\\\"\"}"Options and edge cases
- Escaping starts from the minified document, so the string carries no extra whitespace.
- Escaping an already escaped string adds another layer of backslashes. Unescape once for each layer.
- The input is read as JSON, not run as JavaScript. Loose syntax such as comments or single quotes is repaired before escaping.
- A string value inside a larger document can be expanded in place: select it in the Tree and choose Expand nested JSON string from the More options menu.
- Unescape replaces the input, and Ctrl+Z undoes it.
Private by default
Your document stays in this browser. Tool Kumar parses, converts and creates downloads on your device, with no account or upload step.
JSON escape and unescape questions
- How do I escape a JSON string?
- Paste the JSON document. The String output shows it as one JSON string literal, with each quote, backslash and line break escaped. Copy it wherever a string is expected.
- How do I unescape JSON?
- Paste the escaped string, including its outer quotes. Tool Kumar notices that it holds JSON and offers Unescape JSON, which replaces it with the formatted document.
- Why does JSON.stringify add backslashes to my string?
- The value was already a JSON string, so stringifying it again escapes its quotes. Call JSON.parse once to get the object back, or unescape it here to read the document.