A red error message, a payload an API refused, a config file a tool will not load: invalid JSON rarely announces what is actually wrong with it. The document can be thousands of lines long, and the real culprit is usually a single character. Staring at the whole file is the slowest way to find it.

The fast way is to let a parser point. The free JSON Formatter and Validator on Ovatly validates in your browser and reports the problem in plain words. This guide walks through the discipline that makes that quick, then profiles the five suspects behind almost every invalid document.

Contents

  • Quick answer
  • The method: validate, read, fix one thing, repeat
  • Suspect one: the trailing comma
  • Suspect two: single quotes
  • Suspect three: unquoted keys
  • Suspect four: comments from a config file
  • Suspect five: a missing comma or bracket
  • Worked example: one object, valid and broken
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

Your JSON is invalid because the parser met something the strict JSON standard does not allow. Paste the document into the JSON Formatter and Validator, press Validate only, and read the plain-words error: it names the problem, such as an unexpected character or a missing comma. Fix that one thing and validate again. Work through the errors one at a time, and check the usual suspects first: trailing commas, single-quoted strings, unquoted keys, comments, and missing commas or brackets.

The method: validate, read, fix one thing, repeat

Validate only is the right mode for diagnosis because it checks the document without changing it. Formatting a broken file cannot fix it, and minifying one only makes the hunt harder. Validation either confirms the document parses or hands you an error message in plain words naming what the parser found.

Then comes the discipline that beginners skip: fix only the named problem, and validate again. A parser reads until it meets something it cannot accept, and then it stops, because everything after that point may be misread anyway. A document with four errors will therefore report them one at a time, across four rounds. That is not the tool being difficult; it is the only honest way to read a format where one stray character shifts the meaning of everything after it. Each round takes seconds, and the error is always at or just before the place the parser stopped.

Suspect one: the trailing comma

A comma after the last item in an object or array is natural in JavaScript and in many config styles, and it is flatly invalid in JSON. It usually arrives when you delete the final entry of a list and leave its comma behind, or when a generator writes items with a comma after each one, including the last. The parser reads the comma, expects another value, meets the closing bracket instead, and reports an unexpected character. Delete the comma, not the bracket.

Suspect two: single quotes

JSON strings must use double quotes. Text copied from JavaScript code, a Python dictionary or a hand-written note often arrives wrapped in single quotes, and every one of them is an error. The fix is mechanical: replace the single quotes around keys and string values with double quotes. Watch out for apostrophes inside the text itself while you do it; a name like O'Brien is content, and converting blindly can trade one error for another.

Suspect three: unquoted keys

In JavaScript you can write an object with bare key names. In JSON you cannot: every key must be a double-quoted string. Documents converted quickly from code, or typed by hand by someone thinking in JavaScript, fail on the very first key. If the validator's error points near the start of an object, look at the key before the colon. Quote it, and every key after it, before validating again.

Suspect four: comments from a config file

Comments feel harmless because so many formats allow them, but JSON is not one of those formats. There is no comment syntax in the standard at all, and this validator has no JSONC support, so a comment line pasted from a configuration file is reported as an error like any other stray text. This is the single most common reason a file that "looks fine" fails: it was written for a tool that accepts comments, and strict JSON does not. Remove the comments before validating, or keep the file in a JSONC-aware editor and treat strict JSON as an export format, not the working one.

Suspect five: a missing comma or bracket

The mirror image of the trailing comma: two values with nothing between them, or a bracket opened and never closed. These errors are the ones where the reported position can sit a line or two after the real gap, because the parser only realises something is wrong when it meets the next token. When the error names a missing comma, look just before the reported spot, at the end of the previous value. When a document is deeply nested, validating after each fix matters even more, because one unclosed bracket makes every later line suspect.

Worked example: one object, valid and broken

Here is the reference shape, a small valid object:

{"name":"Ovatly","tools":250,"free":true}

Every key is double-quoted, every string is double-quoted, the number and the boolean are bare, and commas sit only between pairs. Now the same object as it often arrives after a quick hand edit, with the last entry deleted and its comma left behind, and one value single-quoted:

{"name":"Ovatly","tools":250,"free":'true',}

Two errors, reported one at a time. The first validation names an unexpected character where the single-quoted value begins. Fix the quotes, validate again, and the second error surfaces: the trailing comma before the closing brace. Fix that, and the document parses. Two rounds, a few seconds each, no line-by-line staring.

Limitations and honest tradeoffs

The validator checks strict JSON only. That is the right standard for APIs and data exchange, but it means JSONC and JSON5 files, which deliberately allow comments, trailing commas and unquoted keys, will always fail here. They are not broken; they are a different format, and they need an editor that speaks it.

Validation also tells you only that a document parses, not that it is correct. A valid document can still hold the wrong values, the wrong types or a misspelled key, and no parser can catch that. One more caveat if you reformat after fixing: number precision follows JavaScript, so integers beyond 2^53 can lose exactness when the document is rewritten. Validate only, which does not touch the text, avoids that entirely.

Common mistakes

  • Fixing three guesses at once. Change one thing per validation round, or you will not know which change mattered and may add a new error while removing another.
  • Formatting a broken file and hoping. Format cannot repair invalid JSON; it needs a document that already parses. Diagnose with Validate only first.
  • Assuming the error sits exactly where it is reported. The parser reports where it stopped. For missing commas and brackets, the real gap is usually just before that point.
  • Arguing with the standard. If the file needs comments or trailing commas to stay readable, it is JSONC, not JSON. Use tooling for the format you actually have.

FAQs

What does Validate only do differently from Format? Validate only checks your JSON and reports whether it parses, without changing the text at all. Format rewrites it with consistent indentation, and Minify compresses it to one line. When you only need a yes or no answer, Validate only is the safer choice.

Why does my file fail because of comments? Comments are not part of the JSON standard, so the parser reports them as errors. The tool has no JSONC support. Remove the comments before validating, or use a JSONC-aware editor for files that need them.

Why does the validator report only one error at a time? A parser stops at the first problem it cannot read past, because everything after it may be misread. Fix the named error and validate again; the next error, if there is one, will surface then.

Can the tool validate JSONC or JSON5 files? No. Validation follows the strict JSON standard only. Files that rely on comments, trailing commas or unquoted keys need a JSONC or JSON5 aware editor, or a cleanup pass before they can pass here.

Is my JSON uploaded to a server to be checked? No. Parsing and validation run in your browser with JavaScript's built-in JSON parser. Payloads you paste, including ones with API keys or private data, never leave your device.

Conclusion

Invalid JSON is almost never a mystery; it is one of five small things, found one at a time by a parser that tells you plainly where it stopped. Keep the JSON Formatter and Validator open while you edit, validate after every fix, and the document will come right faster than any amount of squinting. If your JSON started life as a spreadsheet export, our guide to converting CSV to JSON for an API or app covers the step before this one. For more guides in this series, see our Data and JSON Tools guides.

References