JSON error and escape reference

Last updated 2026-11-29

Three tables: what each parse error usually means, which escapes are legal inside a string, and what happens to values JSON cannot represent.

Parse errors and what causes them

Browsers change the wording between releases, so match on the cause rather than the exact sentence. Every row below is a syntax problem: the document never reaches the formatting step.

InputMessage you will seeCauseFix
{"a":1,}Unexpected token } or Expected double-quoted property nametrailing comma after the last memberdelete the comma
{'a':1}Unexpected token 'single quotes around a keyuse double quotes
{a:1}Unexpected token akey without quoteswrap the key in double quotes
// noteUnexpected token /a comment at the startremove the comment
{"a":1} extraUnexpected non-whitespace character after JSONtext after the closing bracekeep one document only
{"a":"line break"}Bad control character in string literala real newline inside a stringwrite backslash-n instead
{"a":01}Unexpected numberleading zero in a numberwrite 1
an empty or blank boxPlease enter JSON contentnothing left after trimmingpaste a document

Positions in the message count characters from the start of the string, including whitespace. If the reported position is near the end, look at the last member; a missing closing bracket is usually reported one character past the end of the input.

Legal escape sequences

Only the escapes in this table are valid inside a JSON string. Anything else, including a backslash before an ordinary letter, is a syntax error rather than a literal backslash.

Escape writtenCharacter producedWhen it is needed
backslash + quotea double quote inside the stringany text containing a quote
backslash + backslashone backslashWindows paths and regular expressions
backslash + slasha forward slashoptional, the slash needs no escape
\bbackspace, U+0008almost never
\fform feed, U+000Calmost never
\nline feedmulti-line text kept on one line
\rcarriage returnWindows line endings
\ttab charactertab inside a value
\uXXXXone UTF-16 code unitcharacters you cannot type directly

A pair of backslash-u escapes is needed for characters outside the basic plane, such as many emoji: the first unit is a high surrogate and the second a low surrogate.

What JSON.stringify does to each value

Valid JavaScript values do not always survive serialisation. The table shows the object and array cases, which behave differently for the same value.

ValueInside an objectInside an arrayWhy
undefinedkey omittednullJSON has no undefined
functionkey omittednullfunctions cannot be serialised
Symbolkey omittednullsymbols cannot be serialised
NaNnullnullnot a finite number
Infinitynullnullnot a finite number
DateISO 8601 stringISO 8601 stringDate provides toJSON()
BigIntthrows TypeErrorthrows TypeErrorconvert it to a string first

Omitting a key and writing null are different outcomes: the first removes the member, the second keeps it with an empty value. A parser on the other side may treat a missing field as a default and a null field as an explicit clear, so check which one your schema expects.

Reading a message without guessing

None of these messages mention duplicate keys, precision loss or overflow, because those documents are syntactically valid. Check them separately.

Open the JSON Formatter

Keep reading