Escape text so it fits inside a JSON string (quotes, backslashes, newlines), or unescape a stringified JSON value back to text
Escape text to put it inside a JSON string, or turn an escaped string like {\"a\":1} back into readable text.
How to use it
Choose Escape or Unescape. For Escape, turn on Wrap in quotes to get a complete JSON string, "…" included. Paste the text. Unescape accepts it with or without the surrounding quotes, and names the line and column of a backslash or quote that breaks it. Copy the result. To read escaped JSON, unescape it and open it in the JSON formatter .
Examples
Escape a Windows path and quotes
He said "hi" C:\temp
He said \"hi\"\nC:\\temp
Unescape a log field
{\"event\":\"signup\",\"ok\":true}{"event":"signup","ok":true}Common in logs and message queues where JSON is stored as a string inside JSON.
Read \u escapes
caf\u00e9 \ud83d\ude00
café 😀
Four hex digits are one UTF-16 unit, so an emoji past U+FFFF takes two of them (a surrogate pair).
What gets escaped
Everything else stays as it is: letters with accents, emoji, single quotes and the forward slash /. JSON allows \/ but doesn’t require it.
| Character | Escaped as |
|---|---|
" (double quote) | \" |
\ (backslash) | \\ |
Line break | \n |
Carriage return | \r |
Tab | \t |
Backspace, form feed | \b, \f |
Other control characters (U+0000 to U+001F) | \u0000 style, e.g. \u001b for the Esc character |
Half of an emoji pair on its own (lone surrogate) | \ud83d style |
Sources: RFC 8259: Strings
A JSON string is not a JavaScript or shell string
| JSON | JavaScript | Bash | |
|---|---|---|---|
Quotes | "…" only | "…", '…' or `…` | '…' (literal), "…" (expands $) |
\x41, \' | Not allowed | Allowed | Only inside $'…' |
\u{1F600} | Not allowed: write \ud83d\ude00 | Allowed | Not allowed: $'\U0001F600' (Bash 4.2+) |
Line break | Must be \n | Raw only in `…` | Raw inside quotes |
A single quote | As is | \' inside '…' | End, \', reopen: 'it'\''s' |
Escaping in code
JSON.stringify('He said "hi"') // "He said \"hi\""
JSON.parse('"C:\\\\temp"') // C:\temp
json.dumps("café", ensure_ascii=False) # "café"Questions
- Why is my JSON full of backslashes?
It was stringified twice: a JSON document was stored as a string inside another JSON value (common in logs, SQS/SNS messages and some databases). Unescape it once to get the inner JSON back. - Are single quotes escaped?
No. JSON strings use double quotes, so single quotes are allowed as they are. - Is my text uploaded?
No. Everything runs in your browser, so your text stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first.