Escape JSON for embedding in strings, or unescape stringified JSON back to readable format.
JSON escaping converts a JSON object or string into a format that can be safely embedded inside another string. Special characters like quotes, backslashes, and newlines are escaped with backslash sequences.
| Character | Escaped | Description |
|---|---|---|
| " | \" | Double quote |
| \ | \\ | Backslash |
| Newline | \n | Line feed |
| Tab | \t | Horizontal tab |
| Carriage return | \r | Carriage return |
Escape adds quotes and escapes special characters, making the entire JSON a valid string literal. Stringify (JSON.stringify) converts a JavaScript object to a JSON string, then optionally escapes it for embedding.