JSON Escape / Unescape
Escape JSON strings for safe embedding in HTML, attributes, or other strings — and unescape them back. Handles quotes, backslashes, new lines, and control characters.
Output will appear here…Escape and unescape JSON strings
JSON strings can contain almost any Unicode character, but a small set of characters must be escaped with a backslash to be valid: the double quote, the backslash itself, and the control characters from U+0000 to U+001F (new line, tab, backspace, form feed, and so on). When you need to embed a JSON document inside another string — inside a script tag, inside an HTML attribute, inside a SQL statement — you often need to apply additional escaping on top of the JSON escaping. That is what this tool helps with.
Pick Escape to add the backslashes required for a specific embedding context, or Unescape to remove them. The HTML-safe mode additionally escapes<, >, and & so the result can be safely embedded inside an HTML document without breaking out of the script tag.
JSON escape vs URL encode vs HTML encode
These three forms of escaping are not interchangeable. JSON escaping produces a valid JSON string value — it adds backslashes for characters that are special inside JSON strings. URL encoding (percent encoding) produces something safe to put in a URL. HTML encoding produces something safe to put inside an HTML document. Always pick the form that matches the context you are embedding into.
Unescaping multi-layer escaped strings
It is common to encounter a JSON string that has been escaped more than once — for example, a JSON value that contains a JSON string that contains an HTML string. Each layer of escaping adds another set of backslashes. Run the unescape function multiple times to peel off one layer at a time. Stop when the output stops changing. This is a common debugging step when working with webhooks that wrap payloads in multiple layers of JSON.
What about non-ASCII characters?
The JSON spec allows but does not require non-ASCII characters to be escaped. Most modern JSON serializers write UTF-8 directly — they emit the literal é, あ, or 🎉 rather than the\u00e9 form. Lintify follows that convention and does not escape non-ASCII characters by default. If you need pure ASCII output (for example, for a legacy transport that cannot handle multi-byte characters), post-process the output to convert every character above U+007F to its \uXXXXform.
Frequently asked questions
Common questions about the Escape tool.