JSON Escape and Unescape
Escape any text or JSON so it can sit inside a JSON string, or reverse it to turn a stringified value back into readable JSON. One of our free JSON tools.
Text or JSON
Escaped JSON string
How to escape or unescape a JSON string
- Step 1
Choose a direction
Pick Escape to make a JSON string literal, or Unescape to turn one back into text.
- Step 2
Paste the input
Paste text or JSON to escape, or an escaped string, with or without its outer quotes, to unescape.
- Step 3
Copy the result
Copy the output, or click Use as input to run it through again.
Worked example
{"msg": "Hi \"Sam\"", "path": "C:\\temp"} "{\"msg\":\"Hi \\\"Sam\\\"\",\"path\":\"C:\\\\temp\"}" What escaping does
A JSON string is wrapped in double quotes, so a double quote inside it has to be written as \". The backslash itself is the escape character, so a literal backslash becomes \\. Characters that would break the line, such as line breaks, tabs and carriage returns, become \n, \t and \r, and other invisible control characters become \u followed by four hex digits. Nothing else needs escaping: accented letters, other scripts and emoji are valid inside JSON strings as they are, and so is the forward slash. The result is exactly what JSON.stringify(text) returns in JavaScript or json.dumps(text, ensure_ascii=False) returns in Python.
Stringifying JSON
Sometimes a whole JSON document has to travel as a string: a message body inside another JSON payload, a value in an environment variable, a field in a database column, or a test fixture in source code. Paste the JSON and leave Minify JSON first on: valid JSON is compacted to one line before it is escaped, which keeps the string short. Turn on Wrap in quotes for a complete literal you can paste straight into code, or off when the surrounding quotes already exist.
Unescaping
Switch to Unescape to go the other way. You can paste a full literal with its outer quotes, "{\"a\":1}", or just the inside, {\"a\":1}, as it often appears in logs. Raw line breaks are read as \n, so text copied from a terminal still works. If the unescaped text is itself JSON and Format unescaped JSON is on, it is pretty-printed so you can read it at once.
Values that were escaped twice, for example JSON inside JSON inside a log line, still show backslashes after one pass. Click Use as input and unescape again; each pass removes one layer.
Errors
Unescaping fails when the text is not a valid JSON string. The common causes are a quote that was never escaped, which ends the string early; an invalid escape such as \q or a Windows path with single backslashes like C:\data; and a \u escape without exactly four hex digits. The error names the problem and its column.
Related tools
To make the JSON smaller without escaping it, use the JSON minifier. For Base64 rather than string escaping, use Base64 Encode and Decode, and for query strings use the URL encoder.
Questions and answers
What is the difference between escaping and JSON.stringify?
None for text: escaping a string gives the same result as JSON.stringify(text) in JavaScript. With Minify JSON first on, valid JSON input is minified before it is escaped, which is what JSON.stringify(JSON.stringify(data)) gives you.
Why are backslashes doubled?
A backslash starts an escape sequence in JSON, so a literal backslash has to be written as \\. That is why a Windows path like C:\Users becomes C:\\Users.
Are accented letters and emoji escaped?
No. JSON allows any Unicode character inside strings, so é and 👍 are kept as they are. Only quotes, backslashes and control characters such as line breaks and tabs must be escaped.
How do I unescape a double-escaped string?
Unescape it once, then click Use as input and unescape the result again. Each pass removes one layer of escaping.
Is my text sent anywhere?
No. Escaping and unescaping happen in your browser. Nothing is uploaded or logged.
Related tools
All JSON & Schema toolsNext step
Need this built into your stack?
The team behind SyntaxSnap builds custom code generators, internal developer tools and API integrations.