How to use this tool
- Choose Escape text for ordinary text or Unescape JSON string for an existing JSON string value.
- Paste the input. In unescape mode, include the surrounding double quotes.
- Select Convert JSON string. The escaped result includes its quotes and can be used as one value in a JSON document.
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.
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.
- 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.
- Unicode text may remain readable rather than being converted to ASCII-only escapes. It does not validate the text for another 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.