1. Trailing comma after last item
JSON does not allow a comma after the last element in an object or array. This is one of the most common mistakes, especially when copying from JavaScript.
Bad:
{
"name": "Alice",
"age": 30,
}Correct:
{
"name": "Alice",
"age": 30
}How to fix: Remove the comma after the last property or array element.
2. Single quotes instead of double quotes
JSON requires double quotes for all strings and property keys. Single quotes are invalid.
Bad:
{'name': 'Alice', 'active': true}Correct:
{"name": "Alice", "active": true}How to fix: Replace all single quotes with double quotes. Use a find-and-replace or a JSON formatter.
3. Unquoted property keys
Property names must be enclosed in double quotes. Unquoted keys like JavaScript object shorthand are invalid.
Bad:
{name: "Alice", age: 30}Correct:
{"name": "Alice", "age": 30}How to fix: Wrap every property key in double quotes.
4. Missing comma between items
Each property or array element must be separated by a comma. Forgetting a comma causes a parse error.
Bad:
{"a": 1 "b": 2}Correct:
{"a": 1, "b": 2}How to fix: Add a comma between each pair of properties or array elements.
5. Comments in JSON (not allowed)
JSON does not support comments. Neither // nor /* */ are valid.
Bad:
{
// user data
"name": "Alice"
}Correct:
{
"name": "Alice"
}How to fix: Remove all comments. Use a separate field like "_comment" if you need documentation in the data.
6. Undefined/NaN values
JSON only supports null, not undefined. NaN and Infinity are also invalid.
Bad:
{"value": undefined, "ratio": NaN}Correct:
{"value": null, "ratio": null}How to fix: Use null for missing or invalid values. Omit the key if the value is undefined.
7. Unclosed brackets or braces
Every { must have a matching }, and every [ must have a matching ]. Missing one breaks parsing.
Bad:
{"items": [1, 2, 3Correct:
{"items": [1, 2, 3]}How to fix: Count opening and closing brackets. Ensure each { has } and each [ has ].
8. Extra comma in arrays
A comma with nothing after it (or before the first element) is invalid.
Bad:
[1, 2, 3,]Correct:
[1, 2, 3]How to fix: Remove trailing or leading commas. Same rule as trailing comma in objects.
9. Using JavaScript syntax (functions, variables)
JSON is data only. No functions, template literals, or variable references.
Bad:
{"fn": function(){}, "date": new Date()}Correct:
{"date": "2025-03-07T12:00:00.000Z"}How to fix: Convert functions to strings or omit. Serialize dates as ISO 8601 strings.
10. Incorrect escape sequences
Only certain escape sequences are valid: \", \\, \/, \b, \f, \n, \r, \t, and \uXXXX.
Bad:
{"path": "C:\Users\file.txt"}Correct:
{"path": "C:\\Users\\file.txt"}How to fix: Double backslashes for literal backslashes. Use \uXXXX for Unicode.