How to use this tool
- Enter the source in the input field.
- Choose Escape text or Unescape JSON string. Enable ASCII-only output when encoding if your destination requires escaped non-ASCII characters.
- Valid input updates after a brief typing pause. You can also use the main action button. Resolve errors before copying or downloading.
- Clear input keeps the conversion settings; Undo input change restores the previous inputs after clear or reverse. Reset restores the example and default settings.
Understanding the output
Escaping adds surrounding double quotes and represents embedded quotes, backslashes, and control characters according to JSON string syntax. Unescaping removes that representation and returns the string value. Objects, arrays, numbers, booleans, and null are rejected in unescape mode because this tool is specifically for text.
For a complete JSON object or array, use the JSON Formatter to validate and format its structure.
A quoted greeting on two lines
Text containing He said "Hi". followed by a newline and Next line. becomes "He said \"Hi\".\nNext line." as a JSON string. Unescaping that quoted value restores the actual newline. Encoding café with ASCII-only output produces "caf\u00e9". Reversing that output restores café.
Distinguish a string value from a JSON document
A JSON string is one possible JSON value. It can appear by itself or inside an object or array. If you paste a complete object into escape mode, the object’s written characters become a string; its properties are not parsed. For example, text {"a":1} becomes a quoted string containing braces and escaped quotes. Use a JSON formatter when you intend to keep an object as an object.
Repeated escaping adds another layer. A visible backslash-n sequence in already escaped text becomes a literal backslash followed by n when escaped again. Decide whether your input contains actual line breaks or an encoded representation before converting it.
JSON escaping does not sanitize every destination
A correctly quoted JSON string is appropriate for JSON syntax, but it is not a universal substitute for HTML, SQL, shell, or URL escaping. In particular, ordinary angle brackets can remain in JSON strings. When placing data into a page or command, use the destination’s structured APIs and context-specific handling rather than assuming that quotation alone makes it safe.
Method and supported input
Escape mode uses JSON.stringify on the complete input string. Unescape mode uses JSON.parse and then requires the parsed value to be a string. Neither operation evaluates code embedded in the text.
ASCII-only encoding writes non-ASCII UTF-16 units as four-digit escapes, including both units for supplementary characters. Unescape still requires one quoted JSON string.
- The desired output is a JSON string value or its plain-text contents.
Limitations
- This tool does not format objects or arrays and does not accept JavaScript single-quoted string syntax.
- Readable Unicode is retained by default; enable ASCII-only encoding when needed. JSON string escaping does not validate text for a different output context.
Common questions
Should I remove the output’s surrounding quotes?
Keep them when inserting the result as a JSON value. Removing them changes the syntax; the correct choice depends on where you paste it.
Why does unescape reject a JSON object?
An object is not a string. Use JSON Formatter to inspect object or array data instead.
Does a script tag in the string execute?
No. Parsing treats it as data, and this page displays the result in a text field rather than rendering it as HTML.
Sources and further reading
Reviewed on