How to escape or unescape
The input panel accepts plain text or an escaped JSON string. Nothing runs until you click one of the four buttons.
- Paste text and click Escape. Quotes, backslashes, newlines, tabs, and other control characters are escaped and the result is wrapped in double quotes, ready to drop into a JSON document or a string literal in code.
- Paste an escaped string and click Unescape to get the original text back. Surrounding quotes are optional.
- Paste a whole JSON document and click Stringify JSON to turn it into one escaped string, for example to store JSON inside a JSON field, a config value, or a database column.
- Paste a string that contains escaped JSON (the usual symptom is
{\"key\":...}) and click Parse string to get it back as pretty-printed JSON.
Click Copy or Download .txt when you are done.
Examples
Escape turns the sample text
She said "ship it" on
C:\Users\maya\reports
Tab: here
into
"She said \"ship it\" on\nC:\\Users\\maya\\reports\nTab:\there"
Stringify JSON turns {"name": "Maya", "tags": ["a", "b"]} into
"{\"name\":\"Maya\",\"tags\":[\"a\",\"b\"]}"
and Parse string turns that line back into formatted JSON.
Double escaping and how to avoid it
If a string arrives as "{\\\"name\\\":...}" with doubled backslashes, it was escaped twice: once when the document was stringified and again when that string was put inside another JSON document, which is exactly what happens with a JSON payload stored in a JSON log field. One Unescape removes one layer; run it once per layer, then Parse string. Going the other way, use Stringify JSON once on the document, and do not click Escape on the already-escaped result unless you really want a second layer. The full list of escape sequences is in JSON escape characters.
Limits and notes
- Input up to 5 MB. Everything runs as JavaScript in your browser; nothing is uploaded.
- Escape follows the same rules as
JSON.stringify: non-ASCII characters such aséor emoji stay as they are rather than becoming\uXXXX. Both forms are valid JSON, so other tools may show them differently. - Unescape and Parse string stop with a readable error if the input is not a valid JSON string, for example when it contains a raw newline or a lone backslash.
- Stringify JSON needs valid JSON and minifies the document before escaping it. Objects that cannot be serialised at all are covered in JSON.stringify and circular references.
- To do the same in code rather than by hand, see working with JSON in JavaScript. To repair input that is not quite JSON, use Fix JSON first.