JSON Escape / Unescape
Escape text into a JSON string literal, or decode an escaped string back to readable text.
Escaping and unescaping JSON strings
Escape turns raw text into a valid JSON string body — a double quote becomes \", a newline becomes \n, a tab becomes \t, and (optionally) any non-ASCII character becomes a \uXXXX sequence. Unescape does the reverse: paste a string full of \uXXXX, \n or \t escapes — a log line, an API payload, a stringified blob — and get clean, readable text back. Decoding is lenient, so stray quotes and raw line breaks don't break it.
Need a different flavour? The Unicode escape converter focuses purely on \uXXXX code points, the backslash escape converter handles generic string escaping, and Base64 encodes binary-safe payloads. Everything runs entirely in your browser.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Turning a multi-line block into a valid JSON string value.
- Reading an escaped string from a log back into what it contains.
- Embedding a code snippet inside a JSON payload.
- Checking whether a value has been escaped twice somewhere in a pipeline.
- Producing a JSON literal from text containing quotes and newlines.
Frequently Asked Questions
- Which characters must be escaped in a JSON string?
- The double quote, the backslash, and every control character below U+0020. JSON defines short escapes for backspace, form feed, newline, carriage return and tab, and everything else in that range must use the
\u00XXform. - Does the forward slash need escaping?
- No —
\/is permitted but never required. It exists because embedding JSON inside an HTML<script>block could otherwise produce a literal</script>and terminate the element early, which is a real problem with an escaping solution rather than a JSON rule. - How are characters outside the BMP escaped?
- As a surrogate pair — an emoji becomes two
\uXXXXsequences, because the\uescape only holds 16 bits. That is why an escaped emoji looks like two garbage codes and why splitting an escaped string blindly can leave half a pair behind. - When do I need to escape JSON twice?
- When a JSON document is carried as a string value inside another JSON document — a common shape in message queues and webhook payloads. Each level doubles every backslash, which is why the nested value ends up with
\\"sequences that look wrong and are correct. - Is escaping the same as encoding?
- No. Escaping makes a character safe inside a JSON string literal; encoding turns text into bytes. A UTF-8 document needs no
\uescapes at all for non-ASCII characters — they are legal literally — so escaping them is a compatibility choice rather than a requirement.
Common errors and gotchas
- Double escaping, where a backslash becomes two and the consumer sees a literal backslash.
- Forgetting that a literal newline is illegal inside a JSON string and must be escaped.
- Assuming the JSON escape set matches another language's, which it does not.
- Leaving a lone surrogate after escaping, which is invalid and gets replaced downstream.
- Escaping a value that the JSON serialiser will escape again.