Skip to main content

Validation

How to validate JSON

A single misplaced comma can make an entire document unparseable. Validating JSON tells you whether it's well-formed and, when it isn't, points to exactly where it broke. Here's how to read those errors and fix them fast.

Updated July 20264 min read

What "valid JSON" means

JSON is valid when it follows the format's grammar exactly: double-quoted keys and strings, commas between items but never after the last one, matching brackets and braces, and a single root value. A validator parses the text against those rules — if it parses, it's valid; if it doesn't, the parser stops at the first violation and reports it.

How to validate JSON in the browser

Using the JSON Viewer & Formatter:

  1. Paste your JSON, or open a file.
  2. Valid JSON immediately renders — as a formatted document or a collapsible tree.
  3. Invalid JSON is flagged inline with the error message and the exact line and column of the first problem, so you can jump straight to it.

Because it runs locally, you can validate private payloads without uploading anything.

The most common reasons JSON is invalid

Trailing commas

A comma after the last element is the single most common error. [1, 2, 3,] and {"a": 1,} are both invalid — remove the final comma.

Single quotes

JSON requires double quotes. {'name': 'Ada'} must be {"name": "Ada"}.

Unquoted keys

Object keys are always quoted strings. {name: "Ada"} is invalid JSON even though it's valid JavaScript.

Comments

Standard JSON has no comments. Strip any // or /* … */ before parsing, or use a format like JSON5/JSONC if you truly need them.

Wrapping text

A leading label such as data = , a trailing semicolon, or a JSONP callback wrapper will all break parsing. The document must start with a value ({, [, a string, number, etc.) and end with its close.

Reading a parser error

Messages like Unexpected token } in JSON at position 42 or Unexpected end of JSON input sound cryptic but follow a pattern:

  • "Unexpected token X" — the parser hit X where it expected something else. The real mistake is usually just before that point (a missing comma or an unclosed string).
  • "Unexpected end of input" — a bracket or brace was never closed, so the parser ran out of text while still expecting more.
  • "Expected property name" — usually an unquoted key or a trailing comma right before a closing }.

A validator that reports the line and column turns this into a quick fix: go to the location, look at the character just before it, and correct the nearest structural mistake. For the full ruleset, see JSON syntax explained.

Frequently asked questions

How do I check if JSON is valid?

Paste it into a JSON validator. Valid JSON parses and renders; invalid JSON is rejected with an error message pointing to the first problem, usually with a line and column.

What makes JSON invalid?

The most common causes are trailing commas, single quotes instead of double quotes, unquoted keys, comments, and stray text wrapping the JSON. Any one of these stops it from parsing.

What does 'Unexpected token' mean?

It means the parser reached a character it didn't expect at that position — often a missing comma or bracket just before it, or a value that isn't quoted correctly. Check the reported location and the character right before it.

Is online JSON validation private?

With JSON-Table, yes. Validation runs entirely in your browser, so the data you paste is never uploaded to a server.