How it works
" → \" ↵ → \nA JSON string sits between double quotes, so a quote inside it has to be written \", and the backslash itself becomes \\. Line breaks and tabs can’t appear raw: they become \n, \r and \t, and other control characters become \u00XX. Everything else, accents and emoji included, may stay as it is, or be written as \u escapes for ASCII-only output.
-
Backslash first, then quotes
\ → \\ " → \" -
Control characters
new line → \n · tab → \t · U+0001 → \u0001 -
Wrap it in double quotes
He said "hi" → "He said \"hi\""
JSON escapes
| Escape | Means |
|---|---|
| \" | double quote |
| \\ | backslash |
| \/ | slash (optional, sometimes used in HTML) |
| \n | new line |
| \r | carriage return |
| \t | tab |
| \b | backspace |
| \f | form feed |
| \uXXXX | any character by its code point |
Good to know
- Unescape accepts the string with or without its outer quotes.
- The result matches JavaScript’s JSON.stringify() and PHP’s json_encode() with JSON_UNESCAPED_UNICODE.