JSON Escape & Unescape

Escape and unescape JSON strings instantly. Escape special characters for embedding JSON in strings, or unescape to read raw JSON. Free, no signup.

FreeInstantEscape & unescapeRuns in browser
Raw text / JSON
Escaped output
Advertisement

JSON String Escaping — Special Characters and Why They Need Escaping

JSON strings have a problem: some characters have special meaning in JSON syntax itself. A double quote inside a string would confuse the parser into thinking the string ended early. A backslash introduces escape sequences. A newline character in a string would break the single-line JSON format. Escaping solves this by representing these characters with safe alternatives.

Characters that must be escaped

JSON requires escaping six characters inside strings: double quote ("\"), backslash (\\\), newline (→ \n), carriage return (→ \r), tab (→ \t), and any control characters. Unicode characters can stay as-is in modern JSON, but can optionally be escaped as \uXXXX for maximum compatibility with ASCII-only systems.

The double backslash problem

Windows file paths cause frequent escaping confusion. The path C:\Users\Alice\Documents in JSON becomes "C:\\Users\\Alice\\Documents" — each single backslash must be doubled. When you see quadruple backslashes in JSON, it's representing a path with double backslashes, which represents a path with single backslashes. Two levels of escaping, one level of actual path.

When you need to escape JSON

Embedding JSON inside another JSON string: {"data": "{"name":"Alice"}"}. Storing JSON in database string columns. Passing JSON as a URL query parameter (though URL encoding is also needed). Including JSON in HTML attributes. Embedding JSON in shell commands. In all these cases, the JSON string itself must be escaped for the outer container format.

Frequently asked questions

When do I need to escape JSON?
You need to escape JSON when embedding it inside another string — for example, storing JSON in a database string column, passing it as a URL parameter, or embedding it inside an HTML attribute.
What characters are escaped in JSON?
JSON requires escaping: double quotes (\"), backslashes (\\), and control characters (\n newline, \r carriage return, \t tab, \b backspace, \f form feed).
What is the difference between JSON escape and URL encode?
JSON escape handles special characters inside JSON strings. URL encoding handles characters in URLs. They use completely different escape sequences — do not mix them up.
How do I unescape a JSON string?
Switch to "Unescape JSON" mode, paste your escaped string, and click Unescape. The tool reverses all escape sequences to give you the original text.
Why does my JSON have double backslashes?
A double backslash (\\) in JSON represents a single literal backslash character. This is common in Windows file paths like C:\\Users\\Alice.
Is my data safe?
Yes. All processing runs locally in your browser. Nothing is uploaded.