JSON is a strict text format. A few hard rules decide whether JSON.parse accepts your document or throws SyntaxError.
Those rules are tighter than JavaScript object literals: always double-quote keys and strings, never leave a trailing comma, and stick to the six value types.
Beginner path.
Learn the checklist below, compare valid vs invalid, then run the examples. Next: JSON Comments.
Checklist
Core Rules
Quoted keysObject keys must be double-quoted strings — "name", not name.
Double quotesStrings use " only. Single quotes are invalid in JSON.
CommasSeparate properties and array items with commas — but not after the last one.
No trailing comma{"a":1,} and [1,2,] fail.
No comments// and /* */ are not allowed in strict JSON.
Six types onlystring, number, object, array, boolean, null — no undefined, Date, or function.
Compare
Valid vs Invalid
Same idea: one document follows the rules; the other looks like a JS literal.
No. After the last property in an object or the last element in an array, do not place a comma. JSON.parse rejects trailing commas.
No. Keys must be strings in double quotes. Unquoted keys are fine in JavaScript object literals, not in JSON.
No. // and /* */ are not part of JSON. See the JSON Comments page for safe alternatives like a _comment field.
JSON is stricter text: double-quoted keys and strings, no trailing commas, no undefined, and only the six JSON value types. JS literals allow more shortcuts.