A trailing comma is a comma after the last item in an object or array, like ["math", "code",]. JavaScript, TypeScript, Python and JSON5 all allow it, but standard JSON does not, so JSON.parse and most APIs reject the whole document.
The example above has two trailing commas. JSON Wrench points to the first one, underlines both, and removes them when you press Fix.
Example
{
"name": "Ada",
"skills": ["math", "code",],
}{
"name": "Ada",
"skills": [
"math",
"code"
]
}The error messages you might see
A trailing comma shows up under different names depending on the tool:
Unexpected token } in JSONorUnexpected token ] in JSON(older Chrome and Node.js).Expected double-quoted property name in JSON(newer Chrome and Node.js).JSON.parse: unexpected character(Firefox).Expecting property name enclosed in double quotes(Pythonjson).
Why trailing commas appear
They usually come from editing JSON by hand (deleting the last item but not its comma), from copying a JavaScript or Python object, or from code that builds JSON by joining strings. Config files written as JSONC, such as VS Code settings, allow them too, so copying from those files carries them over.
How to fix them
Delete the comma before each closing } or ]. In a large file that is easy to miss, so paste the JSON above instead: every trailing comma is underlined, and Fix removes all of them at once while leaving commas inside strings untouched.
To avoid the problem in code, build objects in your language and serialize them with JSON.stringify in JavaScript or json.dumps in Python rather than writing JSON strings by hand.
Frequently asked questions
Does JSON allow trailing commas?
No. The JSON standard (RFC 8259) does not allow a comma after the last element of an object or array. JSON5 and JSONC do, but standard parsers reject it.
Will removing the comma change my data?
No. A trailing comma carries no data. Removing it leaves every key and value exactly as it was.