Format Bench › JSON Escape
JSON String Escape and Unescape
Paste raw text and press Escape to get a valid JSON string literal, or paste an escaped string and press Unescape to recover the original text.
● Runs locally. What you paste never leaves this page.
What escaping actually does
A JSON string is delimited by double quotes, so any double quote inside it has to be marked as content rather than a delimiter. That is what escaping means: replacing characters that would otherwise end or corrupt the string with a backslash sequence the parser understands.
| Character | Escaped as | Why |
|---|---|---|
| Double quote | \" | Would end the string |
| Backslash | \\ | Starts an escape sequence |
| Newline | \n | Literal newlines are illegal in JSON strings |
| Carriage return | \r | As above |
| Tab | \t | As above |
| Control characters | \u00XX | Below U+0020, must be escaped |
When you need this
- Embedding a document inside a document. Putting an HTML fragment, a SQL query or another JSON payload into a JSON string field requires escaping the inner text first.
- Writing test fixtures by hand. A multi-line string in a JSON fixture has to have its newlines escaped.
- Reading logs. Log lines often contain a JSON payload that has been escaped once, sometimes twice. Unescaping recovers the readable original.
- Building API requests manually in a shell or a REST client where a value contains quotes or newlines.
Double escaping
If unescaping produces text that still contains backslash sequences, the value was escaped more than once. This happens whenever a JSON document is serialised into a string field of another JSON document, which is extremely common in logging pipelines and message queues. Run the unescape a second time to recover the original. Each pass removes exactly one layer.
Unicode and non-ASCII text
JSON is Unicode by default, so accented characters, non-Latin scripts and
emoji do not need escaping and are left as-is here. They remain valid in any
UTF-8 encoded document. Some systems prefer pure ASCII output and escape every
non-ASCII character to a \uXXXX sequence; both forms parse to the
same string, so this is a transport preference rather than a correctness one.
Characters outside the Basic Multilingual Plane, including most emoji, are
represented as a surrogate pair of two \uXXXX escapes when
escaped that way. That is a quirk of how JSON inherited UTF-16 escapes, and it
is why a single emoji can appear to count as two characters.
Questions
Why does my unescaped text still contain backslashes?
It was escaped more than once, which happens when a JSON document is stored inside a string field of another JSON document. Run unescape again; each pass removes one layer.
Should I include the surrounding quotes?
Include them if you are pasting the result somewhere a complete JSON string value is expected. Leave them off if you are inserting the text between quotes that already exist in your document.
Do I need to escape accented characters or emoji?
No. JSON is Unicode, so those are valid unescaped in any UTF-8 document. Escaping them to \uXXXX sequences is only needed if a downstream system requires pure ASCII.
Are literal newlines allowed inside a JSON string?
No. A raw newline inside a string is a syntax error and must be written as \n. This is the most common reason a hand-written multi-line JSON value fails to parse.