
Options
Paste JSON and every trailing comma is removed as you type, so the result passes strict JSON parsers. The list under the panes shows each comma that was removed with its line number, and the badge at the top confirms whether the JSON is valid now. The fixer reads your JSON the way a parser does, so commas inside strings are never touched. It can also remove doubled commas, add commas that are missing between lines, and strip comments. Everything runs in your browser.
How to remove trailing commas from JSON
- Paste your JSON into the left pane, or click Open file.
- The fixed JSON appears on the right. Each change is listed under the panes, and you can click one to jump to that line.
- Check that the badge says Valid JSON. If it doesn't, the first remaining error is shown with its line and column.
- Click Copy or Download .json.
What is a trailing comma?
A trailing comma is a comma after the last item in an array or object, like the one after "banners" here:
| Invalid JSON | Valid JSON |
|---|---|
["signs", "decals", "banners",] | ["signs", "decals", "banners"] |
{"city": "Staunton", "state": "VA",} | {"city": "Staunton", "state": "VA"} |
JavaScript, TypeScript, Python, and most modern languages allow trailing commas, and many code formatters add them on purpose because they make diffs cleaner. JSON does not. JSON.parse, Python's json module, and nearly every API server reject them with errors like "Unexpected token }" or "Expecting property name enclosed in double quotes". They usually sneak in when JSON is edited by hand or copied out of code.
Other comma problems it fixes
| Problem | Before | After | Option |
|---|---|---|---|
| Trailing comma | [1, 2, 3,] | [1, 2, 3] | Always |
| Doubled comma | [1,, 2] | [1, 2] | Remove extra commas |
| Leading comma | [, 1, 2] | [1, 2] | Remove extra commas |
| Missing comma between lines | "a": 1 then "b": 2 on the next line | "a": 1, then "b": 2 | Add missing commas |
| Comments | // note or /* note */ | Removed | Remove comments too |
| JavaScript-style keys and quotes | {name: 'Ann'} | {"name": "Ann"} | Fix JSON5 syntax |
Missing commas are only added where a line ends with a value and the next line starts a new one, which is almost always what was meant. Every comma that's added or removed is listed so you can check it.
Removing trailing commas in code
A regular expression like /,\s*([\]}])/g is a common quick fix, but it also changes text inside strings, such as "a, }", and can't tell a trailing comma from one inside a comment. A proper fix needs a tokenizer like the one this tool uses. In JavaScript, the JSON5 package's JSON5.parse accepts trailing commas. In Python, the json5 package does the same. Prettier and ESLint can remove them from .json files with their trailing comma settings.
Frequently asked questions
Will it change commas inside my strings?
No. The fixer reads the JSON the way a parser does, so it knows which commas are inside strings. Text like "Staunton, VA" or "a, b, }" is never changed.
Does it keep my formatting?
Yes, by default. Only the commas change, and your indentation, line breaks, and key order stay the same. You can also choose pretty-printed or minified output, and neither one rounds long numbers.
Why is my JSON still invalid after removing trailing commas?
Something else is wrong too. The badge shows the first remaining error with its line and column, plus a hint. Common causes are single quotes, unquoted keys, and comments, which the Fix JSON5 syntax and Remove comments too options handle.
Can I paste a JavaScript object?
Yes. Turn on Fix JSON5 syntax and unquoted keys get double quotes, single-quoted strings are converted, and trailing commas are removed, giving you valid JSON.
Are trailing commas allowed in JSON?
No. The JSON standard (RFC 8259) doesn't allow them, so strict parsers reject them. Formats built on JSON, like JSONC used by VS Code and JSON5, do allow them.
Is my JSON uploaded anywhere?
No. The JSON is fixed by JavaScript in your browser and never sent to a server.
