DATA

How to fix an invalid JSON file

Find the reported error, check the characters that precede it, and revalidate the document after each correction.

A JSON error often comes from a missing or superfluous character. The line number helps to start, but the real cause may be just before the place where the parser stops.

The essential rules of JSON

  • properties and chains use double quotes;
  • the elements are separated by a comma, without a final comma;
  • objects use hooks and hookboards;
  • the allowed values are string, number, object, table, true, false and null ;
  • comments are not part of the standard JSON format.

Six common JSON errors

1. A final comma

{
  "name": "TechAtelier",
  "active": true,
}

Remove the comma placed after the last property.

2. Simple quotes

{'status': 'ok'}

Replace them with double quotes: {"status": "ok"}.

3. Missing comma

{
  "name": "TechAtelier"
  "active": true
}

Add a comma between the two properties.

4. An unclosed hook or hook

Check each level of nesting and reformat the document to view incomplete blocks.

5. A special character not escaped

In a string, a quote must be written \" and an inverted slash \\.

6. A duplicate key

{
  "status": "draft",
  "status": "published"
}

The document can be accepted while producing a different result depending on the library. Keep each property unambiguous.

Method of correction

  1. Keep a copy of the original file.
  2. Read the first error message, not just the last one.
  3. Examine the indicated line and the previous line.
  4. Correct one anomaly at a time.
  5. Repeat the validation until you get a valid syntax.
  6. Then check the expected structure and business rules.

Validate the file without executing it

The TechAtelier validator checks syntax, duplicate keys, depth and consistency of arrays of objects.

Validate my JSON file

Valid syntax does not mean valid data

A document can be perfectly readable while containing an incorrect type, an absent field or a prohibited value. For automated exchange, define a JSON schema that describes the required properties, formats and accepted values.

Precaution before online validation

Remove passwords, tokens, private keys and sensitive personal data before sending a file to a third-party service. When the document contains active secrets, prefer local validation.

Published on 1 August 2026.