Search HoldMyTwist

Fix JSON errors with JSONLint

Find a trailing comma, fix the JSON, and check what a valid result does and does not prove. Follow a small example with real screenshots.

A brass mechanical arm arranging aqua and navy tiles on a workbench

A stray comma can stop an import or automation. JSONLint (opens in a new tab) points to syntax errors so you can fix the text before trying again.

Use this fictional example in a browser. Keep passwords, tokens and customer records out of online practice tools.

1. Paste a small example

  1. Open JSONLint (opens in a new tab). Click the editor to activate it.
  2. Paste the text below. It deliberately has a comma after the final value.
  3. Click Validate.
Text to copy

{
"item": "Notebook",
"quantity": 2,
}

JSONLint editor showing a fictional object with a trailing comma after quantity

JSONLint editor showing a fictional object with a trailing comma after quantity
Open full-size image

2. Remove the trailing comma

The example returns Invalid JSON and error E008, with a line and column. The highlighted closing brace is where the parser notices the problem. Look at the comma on the line above it.

JSONLint validation result showing E008 trailing comma in object at line 4 column 1

JSONLint validation result showing E008 trailing comma in object at line 4 column 1
Open full-size image
  1. Delete the comma after 2. Keep the comma after "Notebook", because another field follows it.
  2. Click Validate again.

Watch out

Valid JSON means the text follows JSON syntax. It does not prove that an address is correct, an order exists or an app accepts those fields. Check the destination's required names and value types before importing or sending the data.

3. Copy the corrected result

The corrected object returns Valid JSON. Its two fields are item, a text value, and quantity, a number.

Text to copy

{
"item": "Notebook",
"quantity": 2
}

JSONLint result showing Valid JSON after the trailing comma is removed

JSONLint result showing Valid JSON after the trailing comma is removed
Open full-size image
  1. Check that the corrected object has no comma after 2.
  2. Click Copy.
  3. Paste into the destination's JSON field or a plain-text editor.
  4. Keep 2 unquoted when the destination expects a number. "2" is text.
  5. Try one harmless record before using a larger file.

If validation still fails

Start with the reported line, then check the line before it. Field names and text need straight double quotes. Separate fields with commas, and close each brace or bracket. The JSON syntax reference (opens in a new tab) shows the allowed structures.

Keep a copy of the original. If you use automatic repair, compare the repaired values with it before continuing. Syntax repair cannot decide what your data was meant to say.

Sources: JSON.org (opens in a new tab); JSONLint privacy policy (opens in a new tab); JSONLint source and licence (opens in a new tab). Screenshots show JSONLint with fictional data and are cropped to the relevant controls.

Share this guide