About the JSON Escape
A JSON string can contain any character, but some must be written with a backslash: the double quote, the backslash itself, and control characters below U+0020 such as newline, tab and carriage return. This tool applies exactly the escaping defined in the JSON specification, using the short forms \n, \t, \r, \b, \f and \uXXXX for anything else in the control range.
Non-ASCII characters are left as they are, because JSON is UTF-8 and does not require them to be escaped; the result is shorter and still valid. Forward slashes are also left unescaped, which is standard. The output has no surrounding quotes, so you can paste it directly between the quotes of a string value in a JSON document or in code.
Use it when embedding an HTML snippet, a file path, a multi-line message or a piece of source code in a JSON field. The JSON Unescape tool reverses the process.
How to use
- Paste the raw text on the left.
- Copy the escaped text on the right.
- Paste it between double quotes in your JSON document.
Common questions
- Why are accented characters not escaped as \u sequences?
- JSON allows any Unicode character directly in a string. Escaping them is optional and makes the output longer, so only characters that must be escaped are.
- Does it add the surrounding quotes?
- No. You get only the contents so it can be pasted into an existing string. Use the JSON Stringify tool for a complete quoted string.
- What about a forward slash?
- It is valid unescaped in JSON and is left alone. Some tools escape it as \/ for embedding in HTML script tags; that is not needed in normal JSON.