JSON Escape and Unescape

Escape quotes, backslashes and line breaks so text fits inside a JSON string, or choose Decode to turn an escaped payload from a log back into formatted JSON.

Input
Output

Escape or unescape in one step

Example: the two lines He said "hi" and second line become "He said \"hi\"\nsecond line".

Which characters JSON escapes

Inside a JSON string, the double quote, the backslash and control characters (U+0000 to U+001F) must be escaped. Everything else, including accented letters and emoji, can appear as is in UTF-8.

CharacterEscape
Double quote "\"
Backslash \\\
New line\n
Carriage return\r
Tab\t
Backspace, form feed\b, \f
Other control characters\u0000 to \u001f
Forward slash /\/ is allowed but not required

Single quotes never need escaping in JSON, and \' is actually invalid. That's a common mistake when JSON is built by hand from JavaScript or SQL strings.

Unescaping JSON from logs

Logs, message queues and some APIs store JSON as a string, so you get something like:

"{\"orderId\":1042,\"items\":[{\"sku\":\"A-17\",\"qty\":2}]}"

Paste it with Decode selected and you get the formatted object back. If it was escaped twice (you still see \" after decoding), click ⇄ Swap and decode again.

Escaping JSON in code

// JavaScript
JSON.stringify('He said "hi"')        // returns: "He said \"hi\""
JSON.parse('"line\\nbreak"')            // "line\nbreak"

// Java with Jackson
String quoted = new ObjectMapper().writeValueAsString(text);

# Python
import json
json.dumps('He said "hi"')            # '"He said \\"hi\\""'
json.loads(escaped)

Let the JSON library escape values for you when building payloads. Concatenating strings by hand is how unescaped quotes end up breaking requests.

Frequently asked questions

How do I escape double quotes in JSON?

Put a backslash before each one: \". Paste your text here with Encode selected and every quote, backslash and line break is escaped for you.

How do I unescape a JSON string?

Select Decode and paste the string, with or without its outer quotes. Escapes such as \", \n and \u00e9 are turned back into the real characters, and JSON inside is formatted.

Do single quotes need to be escaped in JSON?

No. JSON strings use double quotes, so single quotes are ordinary characters. Writing \' is invalid JSON.

Does JSON need non-ASCII characters escaped?

No. JSON text is UTF-8, so é, ü or emoji can be written directly. \u escapes are only needed for control characters, or if a system can only handle ASCII.

Is my data uploaded?

No. Escaping and unescaping happen in your browser.

Related tools

JSON validator to check the unescaped result, JSON formatter, JSON minifier, Encode / Decode and URL encoder.