JSON Escape/Unescape
Escape and unescape JSON strings — ensure valid JSON formatting with proper character escaping.
Output will appear here
Start typing to see live output
All escaping/unescaping happens locally in your browser — your data never leaves your device.
JSON strings must be wrapped in double quotes, so any double quote, backslash or control character (newline, tab, and so on) inside the text has to be written as an escape sequence such as \", \\ or \n. This tool converts plain text into the escaped form that can sit between the quotes of a JSON string value, and converts escaped string content back into readable text.
Escape mode uses the browser's JSON.stringify and returns the result without the surrounding quotes, so you can paste it straight between "..." in your own JSON. It escapes double quotes, backslashes, \b, \f, \n, \r, \t and other control characters (as \u00XX). Forward slashes, single quotes and non-ASCII characters such as e with an accent or emoji are left unchanged, because JSON does not require escaping them.
Unescape mode parses the input as the contents of a JSON string, turning \n into a real line break, \" into a quote and \u0041 into A. A common use is reading a JSON document that was stored as a string inside another JSON document, such as a log message or a message-queue payload. After unescaping, paste the result into the JSON Formatter to pretty-print it. For values going into URLs rather than JSON, use the URL Encoder.
- Choose Escape to turn plain text into JSON-safe string content, or Unescape to reverse it. Switching modes clears the input.
- Paste or type your text into the left panel; the result updates as you type.
- In Unescape mode, paste only the string contents, without the outer double quotes.
- Copy the result from the output panel with the copy button.
- Click Swap to move the output back into the input and flip the mode, which is a quick way to check a round trip.
- Escape and Unescape modes with live output
- Escaping follows JSON.stringify: quotes, backslashes and control characters, with no surrounding quotes added
- Unescapes all JSON escape sequences, including \uXXXX Unicode escapes
- Swap button to feed the output back in the opposite direction
- Character counts and copy buttons for input and output
- All processing runs in the browser
Escaping quotes and a line break
Input: He said "Hello" World Output: He said \"Hello\"\nWorld
Double quotes become \" and the real line break becomes the two characters \n.
Escaping a Windows path
Input: C:\Program Files\App\config.json Output: C:\\Program Files\\App\\config.json
Each backslash is doubled. A JSON parser reads \\ back as a single backslash.
Embedding a JSON document as a string value
Input:
{"id": 1, "tags": ["a", "b"]}
Output:
{\"id\": 1, \"tags\": [\"a\", \"b\"]}
Usage:
{"payload": "{\"id\": 1, \"tags\": [\"a\", \"b\"]}"}Useful for APIs or queues that expect a JSON-encoded string field rather than a nested object.
Unescaping log output
Input: Error at line 1\n\tcaused by: \"timeout\" in caf\u00e9-api Output: Error at line 1 caused by: "timeout" in café-api
\n and \t become a real line break and tab, \" becomes a quote and \u00e9 becomes the character é.
Unescape output is exactly the same as the input
The input is not valid JSON string content, so it could not be parsed and is returned unchanged. Typical causes are an unescaped " in the middle, the outer quotes still attached, a raw line break, or an invalid sequence such as \x41 or \u12.
Remove the surrounding quotes, make sure inner quotes are written as \", and replace invalid escapes. \u must be followed by exactly four hex digits.
Backslashes appear doubled in the output
In JSON a literal backslash is written as \\. This is expected.
No fix needed; any JSON parser will read \\ back as a single backslash.
Text was escaped twice (\\n or \\\" in the result)
The input already contained escape sequences and was run through Escape again, so the existing backslashes were escaped too.
Use Unescape once to get back to plain text, then escape only once. Swap makes this quick to check.
Bad control character in string literal when parsing your JSON
A string value contains a raw newline or tab that was pasted in without escaping.
Run the string value through Escape mode and paste the result back between the quotes.
Which characters must be escaped in a JSON string?
Only three groups: the double quote ("), the backslash (\), and control characters U+0000 to U+001F such as newline and tab. Short forms exist for \b, \f, \n, \r and \t; any other control character is written as \u00XX. Everything else, including non-ASCII text, can appear as-is in UTF-8 JSON.
Do I need to escape forward slashes?
No. JSON allows \/ as an optional escape, and some serializers (PHP json_encode, for example) emit it to avoid "</script>" issues in HTML, but it is never required. This tool does not escape / when escaping, and turns \/ into / when unescaping.
Why does the output not include the surrounding quotes?
The output is meant to be pasted between the quotes of an existing string value. If you need a complete JSON string literal, add a double quote at the start and end.
How is JSON escaping different from JavaScript string escaping?
JSON is stricter. It only accepts double-quoted strings, has no \' or \x41 escapes, and does not allow raw line breaks in strings. JavaScript additionally supports single quotes, template literals, \x and \u{...} escapes. Text escaped for JSON is valid inside a double-quoted JavaScript string, but not always the other way around.
What is the difference between escaping and encoding (URL or Base64)?
JSON escaping only makes text safe inside a JSON string; the result is still readable. URL encoding (percent-encoding) makes text safe inside a URL, and Base64 turns bytes into an ASCII-only representation. Use the Base64 encoder when a system expects binary-safe text rather than a JSON string.
- JSON FormatterFormat, validate and minify JSON with syntax highlighting and error detection.
- JavaScript Escape/UnescapeEscape and unescape JavaScript strings — convert special characters to escape sequences.
- URL Encoder/DecoderEncode text to URL format and decode URL-encoded strings with Unicode support.
- Base64 EncoderEncode and decode Base64 strings instantly — supports text and URL-safe mode.
- HTML Escape/UnescapeEscape and unescape HTML strings — convert special characters to/from entities safely.
- XML Escape/UnescapeEscape and unescape XML strings — properly encode special characters for XML documents.