How to Validate JSON (and Fix the 7 Most Common Errors)

Multi-Toolkit Team7 min read
JSONWeb DevelopmentDeveloper Tools
TL;DR: Validating JSON means checking that your text follows the JSON grammar (RFC 8259) — correct brackets, double-quoted keys, no trailing commas. Paste it into a JSON validator and it tells you the exact line and column of any error. Below are the 7 mistakes that cause almost every failure.

Invalid JSON is one of those problems that stops everything: an API call fails, a config file won't load, a deployment breaks — often with a cryptic message like Unexpected token } in JSON at position 42. The good news is that the vast majority of invalid JSON comes from a small, predictable set of mistakes. Once you can read a validator's output, fixing them takes seconds.

What does "validate JSON" actually mean?

JSON follows a strict grammar defined in RFC 8259. A validator parses your text against that grammar and reports the first place it breaks. Valid JSON means any standard parser — JavaScript's JSON.parse(), Python's json.loads(), etc. — can read it without error.

Validation is about syntax, not shape. "Is this correct JSON?" is a different question from "does this JSON have the fields my app expects?" The second is schema validation — see the JSON Schema Generator for that.

How to validate JSON in 3 steps

  1. Open the JSON Validator and paste your JSON (or drag in a .json file).
  2. Read the result: valid JSON shows a formatted preview; invalid JSON lists each error with its line and column and a suggested fix.
  3. Click an error to jump straight to that spot in the input — or hit Apply auto-fix to repair the common cases automatically.

Everything runs locally in your browser, so it is safe to paste API responses or config that contain tokens or secrets — nothing is uploaded.

The 7 most common JSON errors (and how to fix them)

1. Trailing commas

{ "name": "John", "age": 30, }   // comma after the last value

Legal in JavaScript, illegal in JSON. Remove the comma before the closing } or ]. This is the single most common cause of invalid JSON.

2. Single quotes

{ 'name': 'John' }   // invalid
{ "name": "John" }   // valid

JSON requires double quotes for every key and every string value. Single quotes are never valid.

3. Unquoted keys

{ name: "John" }     // invalid
{ "name": "John" }   // valid

That is a valid JavaScript object literal, but not JSON. Every key must be wrapped in double quotes.

4. Comments

{
  "port": 8080 // the server port  <- invalid
}

JSON has no // or /* */ comments. Remove them, or use JSONC/JSON5 if your tooling supports it (most config loaders do not).

5. Mismatched or missing brackets

{ "items": [1, 2, 3 }   // ] is missing

Every { needs a } and every [ needs a ]. A validator points you to where the structure stops making sense — usually a line or two after the real mistake.

6. Wrong value types

{ "active": True, "count": 01, "note": undefined }   // all invalid

JSON booleans are lowercase true/false. Numbers can't have leading zeros, and undefined and NaN don't exist in JSON — use null instead.

7. Unescaped characters in strings

{ "path": "C:\Users\Ada" }   // backslashes must be escaped

Inside a JSON string, backslashes, double quotes, and control characters (like raw line breaks) must be escaped — \\, \", \n. A literal newline inside a string is invalid.

Reading a validator's error message

Native parser errors are terse (Unexpected token … at position N). A good validator translates the raw position into a line and column and adds a plain-English suggestion — "Trailing comma before }" or "Single quotes are not valid JSON." Fix the first error and re-validate; one mistake often hides the ones after it.

Validate, repair, format — the full flow

Frequently asked questions

Why does my JSON say "unexpected end of input"? A bracket or brace was never closed, or the file was truncated. Check the very end of the document.

Is it safe to paste sensitive JSON? In a browser-based validator like ours, yes — validation happens locally and nothing is sent to a server.

What is the difference between a validator and a linter? A validator checks syntax (is it parseable?). A linter additionally checks style and conventions. For JSON, syntax validation is what you need 99% of the time.

Can comments ever be valid? Not in standard JSON. Some formats (JSONC, JSON5) allow them, but most parsers will reject them.

Wrapping up

Almost every "invalid JSON" error is one of the seven mistakes above. A validator that shows you the exact line, column, and a suggested fix turns a frustrating hunt into a five-second correction.

Validate your JSON for free →

Related free tools: JSON Repair · JSON Formatter · JSON Schema Generator · All JSON Tools


← Back to all articles