Escape a string so it's safe to drop inside JSON — or reverse it. Live preview and copy.
0 B
0 B
About JSON Escape / Unescape
JSON Escape / Unescape converts any string into a JSON-safe literal, escaping backslashes, quotes, control characters, and (optionally) non-ASCII characters as \uXXXX sequences. The reverse mode takes an escaped JSON string and restores the original text. Useful any time you need to embed code, SQL, error messages, or multiline text as a value inside a JSON payload.
How it Works
1Paste or type your raw text into the input on the left.
2Pick Escape to make the text JSON-safe, or Unescape to reverse a previously escaped string.
3Toggle 'Wrap with quotes' to output a full JSON string literal, and 'Escape non-ASCII' to force \uXXXX output.
4Copy the result or use the share link to round-trip the input.
Frequently Asked Questions
What characters have to be escaped in JSON strings?
Per RFC 8259, double quote ("), backslash (\), and the control characters U+0000–U+001F must be escaped. Short escapes exist for \b \f \n \r \t; everything else uses the \uXXXX form.
Why would I escape non-ASCII characters?
Because some transports, log aggregators, or older parsers mangle UTF-8. Forcing \uXXXX escapes makes the output pure ASCII and transport-safe — at the cost of readability.
Is this the same as JSON.stringify?
For strings, yes — Escape with 'Wrap with quotes' produces exactly what JSON.stringify(yourString) would. Unescape is the inverse: it's equivalent to JSON.parse of a quoted string.
Does this escape HTML or SQL?
No. This is strictly JSON string escaping. For HTML entity encoding use the HTML Entities tool; for SQL literals, use parameterised queries in your application code.