Reference
Escaping characters in JSON strings
A stray quote or backslash inside a string is one of the most common ways JSON breaks. Escaping tells the parser which characters are data and which are structure. Here's the complete set of rules, with examples.
Updated July 20264 min read
Why escaping exists
A JSON string is wrapped in double quotes. So how do you put a double quote inside a string without ending it early? You escape it with a backslash. Escaping is how JSON distinguishes characters that are part of your data from the characters that mark where a string starts and stops.
"She said \"hi\""Without the backslashes, the parser would read "She said " as a complete string and then choke on the rest.
Characters you must escape
Two characters always require a backslash inside a string:
\"— a double quote\\— a backslash itself
In addition, control characters (code points below U+0020) must be escaped — you can't put a raw newline or tab inside a JSON string.
The full escape list
\"— double quote\\— backslash\/— forward slash (optional)\b— backspace\f— form feed\n— newline (line feed)\r— carriage return\t— tab\uXXXX— any Unicode character by its four-digit hex code point
Unicode and non-ASCII text
JSON is Unicode. You can write accented and non-Latin characters directly in a UTF-8 file:
{ "greeting": "café — 你好" }Or, if you need pure ASCII output, escape them with \u sequences — "caf\u00e9" is the same string as "café". Characters outside the Basic Multilingual Plane (like many emoji) are written as a surrogate pair of two \u escapes.
A common trap: double-encoding
When you embed JSON inside another JSON string (for example, a payload stored as a string field), every backslash and quote gets escaped again, producing thickets like "{\"name\":\"Ada\"}". That's valid — it's a string whose contents happen to be JSON — but you must parse it twice. If a document looks like it's drowning in backslashes, this is usually why.
Checking escapes
The fastest way to confirm your escaping is correct is to parse the document. Paste it into the JSON Viewer & Formatter — if an escape is wrong, it's flagged inline with the location; if it's right, the string renders as intended. For the broader grammar, see JSON syntax explained.
Frequently asked questions
Which characters must be escaped in JSON?
Inside a string you must escape the double quote (\") and the backslash (\\), plus control characters like newline (\n), tab (\t), and carriage return (\r). Everything else can appear literally.
How do I include a double quote inside a JSON string?
Escape it with a backslash: "She said \"hi\"". The backslash tells the parser the quote is part of the string, not the end of it.
How are Unicode characters written in JSON?
You can include most Unicode characters directly in a UTF-8 document, or escape them as \uXXXX using the character's four-digit hex code point.
Do forward slashes need escaping in JSON?
No. A forward slash (/) may optionally be written as \/, but it is not required. Most tools leave it unescaped.