Trailing commas are the single most common cause of JSON parse failures in real projects.
Loading JSON Validator…
Finds trailing commas with exact line and column
Explains why trailing commas are invalid in JSON
Free, browser-based, no installation
Works on nested objects and arrays
Drop the JSON Validator into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/json/json-validator?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="JSON Validator by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
JavaScript added trailing comma support for array literals in ECMAScript 3 and for object literals in ECMAScript 5 back in 2009. Function call argument lists and parameter lists followed in later editions. Major style guides such as Google, Airbnb, and the Node.js community converged on the practice over the following decade because trailing commas produce cleaner diffs when a list grows or shrinks: adding or removing an item changes a single line rather than two. TypeScript outputs trailing commas in many cases. Prettier inserts them by default. The cumulative effect is that developers see trailing commas every day and absorb them as a default convention, then carry the habit into JSON where the grammar does not permit them.
RFC 8259, the JSON specification, defines the array and object productions with an exact pattern. An array is an opening bracket, optionally followed by a value, then a sequence of comma-then-value pairs, then a closing bracket. The grammar puts the comma between values rather than after values. There is no production that allows a comma immediately followed by a closing bracket. The object rule has the same shape with property pairs. The specification predates ECMAScript 5's trailing comma addition, but the design choice was deliberate: JSON is meant to be minimal, unambiguous, and identical across every implementation in every programming language. Permitting an optional trailing comma would require every parser everywhere to handle it.
The fix for a trailing comma error is always a one-character deletion: remove the comma sitting immediately before the closing brace or bracket. In a deeply nested document there may be several trailing commas at different levels, in which case FixTools reports each one with its own line and column. A useful editor technique is to search for the regular expression that matches a comma followed by optional whitespace and then a closing brace or bracket, replacing each match with just the bracket. Always preview each match before replacing because the same pattern can theoretically appear inside a string literal where the comma is data rather than a syntax error.
Catching trailing commas before they reach production is a high-value CI integration that takes minutes to set up. A GitHub Actions or GitLab CI job that runs jq . over every JSON file changed in a pull request fails the build at the first trailing comma it encounters, blocking the merge. For repositories where Prettier is the source of the trailing commas, the durable fix is a Prettier override that sets trailingComma to none for JSON files specifically; once that override is in place, the formatter stops introducing the very error pattern your downstream parser rejects. A pre-commit hook using the standard check-json hook from the pre-commit framework adds another layer of defence on the developer machine. For template-generated JSON, add a test that round-trips a representative output through JSON.parse so any future regression in the template fails the test suite before the change reaches production. Multiple layers of checking compound to eliminate the recurring debugging cost of trailing comma failures.
Paste JSON that has a trailing comma error. FixTools will find the exact position of the comma so you can remove it and revalidate.
Step-by-step guide to fix trailing comma in json:
Paste the JSON with the trailing comma
Copy the failing JSON from wherever it lives, whether a config file, an API response, the output of a template, or a generated document. Paste the full content into the FixTools input area so the validator can scan the entire structure. If the failing region is large, paste the whole document anyway rather than trying to extract just the section, because nested errors can cascade and a partial paste may hide them.
Click Validate
Click the Validate button to run the parse. The validator reports the first failure as Unexpected closing brace or Unexpected closing bracket along with the exact line and column. The reported position lands on the closing character that the parser saw after the trailing comma, not on the comma itself, because the parser only realised the comma was trailing once it reached the bracket.
Go to the reported line
Open the source file in your editor and jump to the reported line and column. The closing brace or bracket at that position is what the validator flagged. The actual trailing comma is the character immediately before that closing character. Position your cursor between the comma and the bracket so you can delete the comma without accidentally removing the bracket or any other surrounding content.
Delete the comma
Delete only the trailing comma. Do not delete the closing bracket or any whitespace that you wanted to keep for readability. The bracket itself is correct and necessary. After the deletion, the structure should read as value-then-bracket with no comma between them, which is what the JSON grammar requires. Save the file once the deletion is complete.
Revalidate
Paste the updated content into FixTools and click Validate again. JSON parsers fail fast, so a second trailing comma further into the document may now be visible that was hidden behind the first one. Repeat the locate-and-delete cycle for every reported trailing comma until the validator returns a green result. Then fix the source generator so the same failure does not recur on the next document it produces.
Common situations where this approach makes a real difference:
JavaScript developer
A developer copies a JavaScript object literal from their code into a JSON config file. The object has trailing commas from Prettier formatting. The config loader rejects the file with a parse error on startup. The developer pastes the config into FixTools and sees three trailing commas flagged at different nesting levels in the same document. They delete each one and revalidate after each deletion. The fix takes under two minutes from initial error message to working config. The lesson sticks: JavaScript object literals are not interchangeable with JSON, even when they look identical.
Template engineer
A backend template generates JSON for a configuration endpoint by looping over a list of properties and appending a comma after each one. The loop does not special-case the last iteration, so every generated response carries a trailing comma. Pasting a single response into FixTools confirms the issue in seconds. The real fix is in the template: either iterate with index awareness so the last item omits the comma, or build a comma-separated list using a join operation that handles the boundary correctly. Future responses now validate cleanly.
Config file maintainer
A developer edits JSON-based infrastructure configs in VS Code with the Prettier extension enabled. Prettier is configured for JavaScript with trailingComma set to all, and the team forgot to override the setting for JSON files. The formatter adds trailing commas every time the developer saves. FixTools finds twelve trailing commas in the file. The permanent fix is to add a JSON-specific override in the Prettier config or to add the config file to a .prettierignore entry that excludes it from formatting entirely.
API response debugger
An API response from a legacy system sometimes contains trailing commas in specific response types under specific load conditions. The client team finds the failure intermittently in production logs. They reproduce the conditions in a test environment, capture the raw response with the trailing comma intact, and paste it into FixTools to confirm the pattern. While the upstream team works on a permanent fix, the client implements a defensive trailing-comma-stripping pass on receipt so the application continues to function for affected requests.
Get better results with these expert suggestions:
The error points to the bracket, not the comma
When the validator reports a trailing comma failure, the line and column reference the closing brace or bracket that the parser encountered, not the trailing comma itself. The parser does not consider the comma to be a problem until it reaches the closing character and realises there is no following value. The actual trailing comma is one character to the left of the reported position. Delete the comma there, leave the bracket in place, and the structure becomes valid.
Use regex to find all trailing commas at once
In any code editor that supports regular expression search, the pattern comma followed by optional whitespace and then a closing brace or bracket finds every trailing comma in a file in one pass. Replace each match with just the captured bracket. Always step through matches with the preview before bulk-replacing because the same pattern can theoretically appear inside a string literal where the comma is data rather than a syntax error and the replacement would corrupt the value.
Configure Prettier to avoid trailing commas in JSON
If Prettier is formatting your JSON files and adding trailing commas, add a JSON-specific override in your Prettier configuration that sets trailingComma to none for files matching the JSON extension. Alternatively, add JSON files to your .prettierignore so the formatter skips them entirely. Either approach stops the formatter from introducing the very error pattern your downstream parser rejects, eliminating a recurring source of build failures.
Trailing commas are valid in JSON5 and JSONC
If you have a tool that accepts trailing commas without complaint, that tool is parsing the input as JSON5 or as JSON with Comments rather than as strict RFC 8259 JSON. Standard JSON.parse calls in browsers and Node.js will reject the same input. If your workflow legitimately needs trailing commas in configuration files for diff cleanliness, use a parser library that explicitly supports JSON5, such as the json5 npm package, rather than hoping the standard parser will accept the input.
More use-case guides for the same tool:
Other tools you might find useful:
Open the full JSON Validator — free, no account needed, works on any device.
Open JSON Validator →Free · No account needed · Works on any device