Common causes
1. The last property was deleted or moved
Removing the final line of an object leaves the comma of the line above dangling. This is the most common source, especially in package.json and other hand-edited config.
{
"name": "pastekit",
"private": true,
}{
"name": "pastekit",
"private": true
}2. A trailing comma at the end of an array
Lists that grow one line at a time often end with a comma. Chrome reports it as an unexpected ], Python 3.12 and earlier as “Expecting value”.
{"allowedOrigins": ["https://example.com", "https://admin.example.com",]}{"allowedOrigins": ["https://example.com", "https://admin.example.com"]}3. Copied from JavaScript or a JSONC file
Code formatters such as Prettier add trailing commas to JavaScript objects, and JSONC files such as tsconfig.json and VS Code settings allow them. Pasting that text into a strict JSON parser fails. Use a JSONC or JSON5 parser for those files, or remove the commas.
{
"compilerOptions": {
"strict": true,
"target": "ES2022",
},
}{
"compilerOptions": {
"strict": true,
"target": "ES2022"
}
}4. JSON built by a loop that appends ", " after every item
Templates and string-building loops that write a comma after each element leave one after the last. Let a serializer produce the text instead.
items_json = "[" + "".join(f'"{sku}", ' for sku in skus) + "]"items_json = json.dumps(skus)Frequently asked questions
Why does JavaScript accept trailing commas but JSON does not?
JSON was frozen as a small subset of JavaScript syntax in the early 2000s, before trailing commas in object literals were standard. The JSON grammar has never changed, so they remain invalid in every compliant parser.
Which formats allow trailing commas?
JSON5 and JSONC (JSON with comments, used by tsconfig.json and VS Code) both allow them. YAML flow collections allow them as well. Plain JSON, JSON Lines and package.json do not.
What does Python 3.13 say about trailing commas?
Python 3.13 added a specific message, “Illegal trailing comma before end of object” (or “of array”), pointing at the comma itself. Earlier versions report “Expecting property name enclosed in double quotes” or “Expecting value”.
Can PasteKit remove trailing commas for me?
Yes. Click Fix it: it removes every trailing comma, along with other common problems, and shows the changes as a diff before you accept them.