How to Validate JSON

Understand JSON syntax rules, the most common errors like trailing commas and single quotes, and the difference between syntax validation and JSON Schema.

5 min read Updated Jun 2026

Quick Answer

A JSON validator (also called a JSON linter, JSON syntax checker, or JSON lint tool) parses your input against the JSON specification (RFC 8259) and tells you whether it's valid. If not, it shows you exactly what's wrong and where.

To validate JSON or check JSON for errors, paste your text and the tool reports any parse errors immediately.

If you have JSON to validate right now, use the tool directly.

Try the JSON Validator →

What Is JSON Validation?

JSON (JavaScript Object Notation) has a precise grammar defined in RFC 8259. Any text either satisfies that grammar or it doesn't. A validator is a parser that reports the verdict: valid, or the specific error that caused parsing to fail.

This sounds simple, but JSON is stricter than most people expect. Text that looks right: a JavaScript object with single-quoted strings, or a config file with comments, often fails validation because it violates rules that aren't obvious until you read the spec.

How It Works

The validator passes your text through a parser. The parser builds a tree of values (objects, arrays, strings, numbers) and stops the moment it encounters something the JSON spec forbids. The output is either "valid" or a specific error: "unexpected token", "trailing comma", "unterminated string", along with a character offset or line number.

For example, submitting {"name": "Alice",} to a JSON syntax checker returns an error because the trailing comma after "Alice" is invalid. The validator identifies the position of the }, and tells you what rule it violates.

The Rules

JSON has six value types, strict string rules, and a short list of things that are explicitly forbidden.

Valid value types:

  • String, must use double quotes: "hello"
  • Number: decimal notation, no leading zeros (except 0 itself): 42, -3.14, 1.5e10
  • Boolean: lowercase only: true, false
  • Null: lowercase: null
  • Object: keys must be double-quoted strings: {"key": "value"}
  • Array: ordered list of values: [1, "two", null]

Not allowed:

  • Single-quoted strings: 'hello'
  • Unquoted object keys: {key: "value"}
  • Trailing commas: [1, 2, 3,]
  • Comments: // this or /* this */
  • Special number values: NaN, Infinity, -Infinity
  • The value undefined
  • Functions, dates, regular expressions, or any other JavaScript-specific types

When Validation Saves You Time

  • API 400 errors: A request body fails with "invalid JSON" and the framework gives no line numbers. Paste the payload into a validator to find the offending character.
  • Config files: package.json, tsconfig.json, CI pipeline configs, and deployment manifests are often hand-edited. A stray trailing comma can break a build silently.
  • Webhook payloads in logs: Checking whether a third-party service is sending malformed JSON, or whether your logging truncated the payload.
  • Copy-paste from documentation (JSON in README files and API docs is often slightly malformed) a comment left in, a JavaScript value used as an example. Validate before using.
  • Before committing data files: Validating .json files in CI catches syntax errors before they reach production.

Common Mistakes

You May Also Need

You may also need

Next steps

Continue Learning