What escaping and unescaping actually do
JSON requires certain characters to be escaped inside string values: double quotes become \", backslashes become \\, and control characters (newlines, tabs, carriage returns) become \n, \t, \r. Unicode code points outside the ASCII printable range can be represented as \uXXXX sequences. This tool wraps raw text in JSON.stringify() for escaping, and iteratively applies JSON.parse() for unescaping -- handling multi-level escaped strings (strings-within-strings) that commonly appear in log files, message queues, and serialized API responses.
Round-trip in two clicks
- 1Paste your text in the left editor. The tool auto-detects whether the input looks escaped (starts with a double quote) or plain.
- 2The mode toggle switches automatically: Escape for raw text, Unescape for escaped strings. Override manually if needed.
- 3Click Process. The escaped or unescaped result appears on the right.
- 4For multi-level unescaping (e.g., a JSON string embedded inside another JSON string), the tool unwinds all layers and reports how many escape levels it detected.
Encoding details
- `JSON.stringify`-based escaping — Escape mode calls
JSON.stringify(input), producing a valid JSON string literal with all special characters properly escaped perRFC 8259section 7. - Multi-level unwinding — Unescape mode iteratively parses the string -- if the result is itself a quoted JSON string, it parses again, counting levels. Log pipelines often double- or triple-escape payloads; this handles them all.
- Escape-level detection — A badge shows how many escape layers were detected (e.g., "2 escape levels"), so you know exactly how many times the string was wrapped.
- Pretty-print on final unescape — If the innermost unescaped value is valid JSON, the output is pretty-printed with
JSON.stringify(parsed, null, 2)instead of dumped as a raw string. - Auto-mode switching — When you paste input that starts with a double quote, the tool automatically switches to Unescape mode. Plain text defaults to Escape.
Debugging scenarios
- Log file payloads — Application logs often serialize JSON payloads as escaped strings inside a larger JSON log line. Paste the escaped fragment to recover the original structure.
- Message queue inspection — SQS, Kafka, and RabbitMQ messages frequently carry JSON-in-JSON. Unescape to read the inner payload without writing a throwaway script.
- API response debugging — Some APIs return stringified JSON inside a "data" field. Unescape it to see the actual object.
- Building string literals — When constructing a JSON payload programmatically and you need to embed a block of text as a string value, escape it here to get the properly quoted version.
- Clipboard round-trips — Copy a JSON object, escape it, embed it in another JSON document, then unescape later to verify nothing was lost.
Escape and unescape round-trip
// Original JSON:
{"name": "O'Brien", "path": "C:\\Users\\data"}
// After escaping (JSON string literal):
"{\"name\": \"O'Brien\", \"path\": \"C:\\\\Users\\\\data\"}"
// After unescaping back:
{"name": "O'Brien", "path": "C:\\Users\\data"}Edge cases explained
Why does unescaping sometimes produce pretty-printed JSON?
When the innermost string parses as valid JSON, the tool formats it with JSON.stringify(parsed, null, 2) for readability. If it is not valid JSON, the raw string is returned as-is.
What does "2 escape levels detected" mean?
It means the input is a JSON string whose value is itself a JSON string. Two calls to JSON.parse() were needed to reach the original content. This happens when JSON is serialized inside a log line that is itself JSON.
Does this handle Unicode escape sequences like \u00e9?
Yes. JSON.parse() natively resolves \uXXXX sequences to their UTF-16 code points. The tool inherits that behavior -- \u00e9 becomes e with an acute accent.
Can I escape arbitrary binary data?
This tool handles text (UTF-8 strings). For binary data, encode it as Base64 first, then escape the Base64 string if needed.