Fix trailing commas in JSON
Strict JSON rejects a comma after the last property or array element. Find it, fix it, and format the result locally — nothing is uploaded.
Why trailing commas fail
JSON objects and arrays cannot end with a comma before } or ]. Many JavaScript object literals allow the trailing comma; JSON.parse and most API gateways do not. A config copied from a JS module into an API body is a common source of “Unexpected token” errors on the final property.
{
"id": "00127",
"tags": ["mug", "blue",]
}The comma after "blue" is illegal in JSON. The same rule applies after the last key in an object.
Steps in this browser
- Paste the payload into the JSON Formatter.
- Run validate or format. The first offending line and column are reported when the document is strict-invalid.
- Remove the trailing comma (or convert the document in the source emitter).
- Format again and confirm a clean tree. Minify only after the document validates.
Related mistakes
Single-quoted strings, unquoted keys and // comments are also rejected by strict JSON even though they appear in some config dialects. Large integers may validate here but lose precision in JavaScript Number — compare with your application’s parser. For CSV handoffs that become JSON, see CSV to JSON.