cannot close a script tag when JSON is embedded in HTML, which is what the Escape / option does."}}, {"@type": "Question", "name": "What is the difference between escaping and stringifying?", "acceptedAnswer": {"@type": "Answer", "text": "Escaping turns plain text into the inside of a JSON string. Stringifying takes a whole JSON value, serializes it and then escapes it, so the result is a string that contains JSON, like JSON.stringify(JSON.stringify(obj)) in JavaScript."}}, {"@type": "Question", "name": "Why does my string contain \\\\n or \\\\\\\" after unescaping?", "acceptedAnswer": {"@type": "Answer", "text": "It was escaped twice, which happens when JSON is stored inside another JSON string or a log line. The tool detects this and offers an Unescape again button."}}, {"@type": "Question", "name": "How are emoji and non-English characters handled?", "acceptedAnswer": {"@type": "Answer", "text": "They are valid in JSON as is, so they are kept by default. With the \\uXXXX option they are written as UTF-16 escapes; emoji outside the Basic Multilingual Plane become a surrogate pair such as \\ud83d\\ude00."}}, {"@type": "Question", "name": "Are single quotes escaped?", "acceptedAnswer": {"@type": "Answer", "text": "No. JSON strings are always delimited by double quotes, so a single quote needs no escaping, and \\' is actually invalid in JSON. When unescaping, \\' is accepted and turned into a plain single quote."}}, {"@type": "Question", "name": "Is my data sent to a server?", "acceptedAnswer": {"@type": "Answer", "text": "No. All escaping and unescaping happens in your browser with JavaScript."}}]}]
Turn any text into a safe JSON string value, turn an escaped string with \n and \" back into readable text, or stringify a whole JSON object so it can be embedded inside another string. Results update as you type.
0 characters
Advertisement
Advertisement
How to use the JSON Escape / Unescape
Choose a mode: Escape (text to JSON string), Unescape (JSON string to text), Stringify JSON (object to string) or Parse stringified (string back to object).
Paste your input on the left. The result appears on the right instantly.
Set the options, such as wrapping the result in double quotes or escaping non-ASCII characters as \uXXXX.
Press Swap to send the output back as input in the opposite mode, which is a quick way to check a round trip.
Copy or download the result.
JSON escape sequences
Character
Escaped as
Required?
Double quote "
\"
Yes
Backslash \
\\
Yes
Line feed (new line)
\n
Yes
Carriage return
\r
Yes
Tab
\t
Yes
Backspace / form feed
\b / \f
Yes
Other control characters U+0000–U+001F
\u0000 … \u001f
Yes
Forward slash /
\/
No (optional)
Any other character, e.g. é or 😀
é, 😀
No (optional)
Only these escapes exist in JSON. Sequences that work in JavaScript or other languages, such as \', \x41 or \0, are invalid in a JSON document.
Escape vs. stringify: an example
Escaping the text Say "hi" gives Say \"hi\", which you can place between double quotes in JSON: {"msg": "Say \"hi\""}.
Stringifying the object {"msg": "hi"} gives "{\"msg\":\"hi\"}": a single JSON string whose content is JSON. This is common in message queues, logs, AWS event payloads and database columns that store JSON as text. Use Parse stringified to turn it back into a readable object, even when it was stringified more than once.
Doing it in code
In JavaScript, JSON.stringify(text) escapes a string and adds the quotes; JSON.parse(str) reverses it. In Python use json.dumps(text) and json.loads(s); pass ensure_ascii=False to keep non-ASCII characters as is. In PHP use json_encode with JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE to avoid \/ and \uXXXX output.
Frequently asked questions
Which characters must be escaped in a JSON string?
The double quote (\"), the backslash (\\) and the control characters U+0000 to U+001F. Line feed, carriage return, tab, backspace and form feed have short forms (\n, \r, \t, \b, \f); the others are written as \u0000 to \u001F. Everything else, including emoji, may appear as is.
Do I need to escape a forward slash in JSON?
No. \/ is allowed but optional. Some systems escape it so that the text </script> cannot close a script tag when JSON is embedded in HTML, which is what the Escape / option does.
What is the difference between escaping and stringifying?
Escaping turns plain text into the inside of a JSON string. Stringifying takes a whole JSON value, serializes it and then escapes it, so the result is a string that contains JSON, like JSON.stringify(JSON.stringify(obj)) in JavaScript.
Why does my string contain \\n or \\\" after unescaping?
It was escaped twice, which happens when JSON is stored inside another JSON string or a log line. The tool detects this and offers an Unescape again button.
How are emoji and non-English characters handled?
They are valid in JSON as is, so they are kept by default. With the \uXXXX option they are written as UTF-16 escapes; emoji outside the Basic Multilingual Plane become a surrogate pair such as \ud83d\ude00.
Are single quotes escaped?
No. JSON strings are always delimited by double quotes, so a single quote needs no escaping, and \' is actually invalid in JSON. When unescaping, \' is accepted and turned into a plain single quote.
Is my data sent to a server?
No. All escaping and unescaping happens in your browser with JavaScript.