How to use this JSON Escape / Unescape tool
You can use this page in two ways. If you have readable text that needs to be inserted into
a JSON string, click Escape JSON. If you already have escaped text and
want to make it human-readable, click Unescape JSON. The output appears
instantly in the second panel.
- Paste your text or escaped JSON string into the input field.
- Click Escape JSON to convert special characters into JSON-safe sequences.
- Click Unescape JSON to convert escaped content back into readable text.
- Review the output.
- Copy the result or download it as a text file.
If you are working with full JSON documents instead of a plain string, use the
JSON Formatter or
JSON Validator. If you need to simplify nested objects,
try the JSON Flattener.
Example: escaped output
Input:
He said: "Hello
World"
Escaped output:
He said: \"Hello\nWorld\"
Example: unescaped output
Input:
He said: \"Hello\nWorld\"
Unescaped output:
He said: "Hello
World"
Which characters JSON actually requires you to escape
The list is shorter than most people think. Inside a JSON string, RFC 8259 forces you to
escape exactly two visible characters — the double quote " (as \")
and the backslash \ (as \\) — plus every control character in the
range U+0000 to U+001F. That control range is where the real bugs live, because it includes
newline, carriage return, and tab. A literal line break inside quotes is not a formatting
quirk; it is invalid JSON, which is why a multi-line value pasted straight into a string
fails to parse and must be written as \n.
Everything else is legal unescaped. Notably the forward slash / does
not need escaping, even though many tools emit \/ — that is optional,
not required. Accented letters and other printable Unicode can appear as-is in a UTF-8
document; escaping them to \u sequences is a choice, not an obligation.
Emoji, astral characters, and surrogate pairs
Characters above U+FFFF — most emoji, many CJK extensions, historic scripts — live in what
Unicode calls the astral planes, and they cannot be written as a single four-digit
\u escape. JSON inherits UTF-16's solution: they are encoded as a
surrogate pair of two escapes. So 😀 (U+1F600) becomes
\uD83D\uDE00, not one code point. A naive escaper that walks the string one
UTF-16 unit at a time and escapes each in isolation can split a pair or mishandle it,
corrupting the emoji into a replacement character.
This is also why you sometimes see a single emoji "count" as two characters or break when
truncated — cutting a string between the two halves of a surrogate pair leaves a lone,
invalid surrogate. Modern JSON.stringify guards against emitting broken output
by escaping any lone surrogate, but string-slicing code upstream can still create the
problem before escaping ever runs.
Double-escaped JSON: a document inside a string
The backslash pile-up everyone hits in logs and message queues comes from putting a whole
JSON document inside a JSON string value — a stringified payload embedded in another
payload. Each nesting level escapes the level below it, so an inner " becomes
\", then \\\" one level further out, and the backslashes roughly
double each time. A value that reads
"{\"user\":\"ada\"}" is one JSON string whose content is another JSON
object.
To read it, unescape once per level of nesting: the first pass yields
{"user":"ada"}, which you can then parse or format normally. Unescaping too
many times mangles any backslashes that were genuinely part of the data, so count the layers
rather than stripping until it "looks clean".
Escaping the slash for safe HTML embedding
There is one good reason to escape the optional forward slash. When you drop JSON straight
into an HTML <script> block, the browser's HTML parser scans for the
literal text </script> before the JavaScript ever runs. If a string value
contains </script>, it closes the tag early and any following content can
execute — a cross-site scripting vector. Escaping the slash as <\/script>
keeps the value identical to JavaScript while hiding the closing sequence from the HTML
parser.
This page handles string content only; it does not validate a whole document. For that,
reach for the JSON Validator or the
JSON Formatter.
Frequently asked questions
What does escaping JSON do?
Escaping JSON converts special characters into safe escaped sequences so text can be
used inside a JSON string without breaking the format.
Can this tool unescape JSON strings too?
Yes. You can escape readable text and also unescape JSON-escaped string content back
into a more readable form.
Is this tool free to use?
Yes. This JSON Escape / Unescape tool is free to use and works directly in your browser.
Can I copy or download the result?
Yes. After generating the output, you can copy it to the clipboard or download it as a
text file.
Who can use this tool?
Developers, testers, API users, data engineers, students, and anyone handling JSON
string content can use this tool.
Does escaping validate my entire JSON document?
No. Escaping only helps with string content. Use a validator or formatter if you need
to check a full JSON document.