{ } JSON Validator & Formatter

Learn JSON: syntax, validation and common errors

Everything you need to read, write and debug JSON with confidence, including what the different JSON specifications actually mean when you pick one in a validator.

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based format for exchanging data. It was popularized by Douglas Crockford in the early 2000s and has become the default format for web APIs, configuration files and data storage. Despite the name, JSON is language-independent: practically every programming language can parse and produce it.

{
  "name": "Ada Lovelace",
  "born": 1815,
  "fields": ["mathematics", "computing"],
  "active": false,
  "spouse": null
}

The six JSON data types

TypeExampleNotes
String"hello\nworld"Always double quotes. Supports escapes like \n, \t, \", \\ and \uXXXX.
Number-3.14, 2.5e10No leading zeros (01 is invalid), no NaN/Infinity, no hex.
Booleantrue, falseLowercase only.
NullnullLowercase only. Represents “no value”.
Object{"key": "value"}Unordered key/value pairs. Keys must be double-quoted strings.
Array[1, "two", null]Ordered list; elements may be of mixed types.

The most common JSON errors (and their fixes)

These account for the vast majority of “invalid JSON” failures. The JSON Validator & Formatter pinpoints each one with a line and column number, and its Auto-fix button repairs most of them in one click.

1. Trailing commas

{ "a": 1, "b": 2, }   ← invalid
{ "a": 1, "b": 2 }    ✓ valid

JavaScript tolerates a comma after the last item; JSON never does.

2. Single quotes

{ 'name': 'Ada' }     ← invalid
{ "name": "Ada" }     ✓ valid

3. Unquoted keys

{ name: "Ada" }       ← invalid (valid JavaScript, not JSON)
{ "name": "Ada" }     ✓ valid

4. Comments

{
  "port": 8080  // the dev port   ← invalid
}

Standard JSON has no comment syntax. Variants like JSONC (used by VS Code settings) and JSON5 allow them, but strict parsers reject them.

5. Missing commas or brackets

A forgotten , between properties or an unclosed {/[ cascades into confusing errors further down the document. Validate early and often.

6. Special values from other languages

NaN, Infinity, undefined and Python's None/True/False are all invalid in JSON. Use null, true, false or strings.

JSON specifications: RFC 8259 vs RFC 7159 vs RFC 4627 vs ECMA-404

JSON has been standardized several times. The grammar barely changed. What changed is what a document is allowed to contain at the top level and how it should be encoded. This is exactly what the validation dropdown in JSON Validator & Formatter selects.

SpecYearKey points
RFC 46272006The original IETF spec. The top-level value must be an object or an array. A bare "string" or 42 is not a valid JSON text.
ECMA-4042013The ECMA standard. Pure grammar: any JSON value (including strings, numbers, booleans, null) is a valid document. Says nothing about encoding or interoperability.
RFC 71592014Relaxed RFC 4627: any value may appear at the top level. Recommends UTF-8 and warns about duplicate keys and number precision.
RFC 82592017The current standard. Same grammar as RFC 7159, but UTF-8 is required for JSON exchanged between systems, and a byte-order mark must not be added.

Practical takeaway: validate against RFC 8259 unless you must interoperate with a legacy system that expects RFC 4627's object-or-array rule.

Numbers and precision: a silent data-loss trap

The JSON grammar puts no limit on number size, but most parsers (including JavaScript's JSON.parse) decode numbers as IEEE-754 doubles. Integers are only exact up to 2^53 − 1 = 9007199254740991. Beyond that, digits are silently rounded:

JSON.parse('{"id": 18800000000000000123}').id
// → 18800000000000000000  (last digits lost!)

This bites hard with database IDs (Twitter/X snowflake IDs are a famous example). Fixes: transmit big IDs as strings, or use a lossless parser. JSON Validator & Formatter auto-detects long integers and switches to its lossless parser so the digits survive formatting and editing.

How JSON validation works

A JSON validator does two things: it tokenizes the text (splitting it into strings, numbers, punctuation) and then parses the token stream against the JSON grammar. When something violates the grammar, a good validator reports where (line and column) and what was expected. “Expected ',' between properties” is fixable in seconds, while a generic “Unexpected token” is not. JSON Validator & Formatter additionally keeps parsing after the first error so you can see and fix several problems in one pass, and highlights each error range directly in the text.

Frequently asked questions

Are comments allowed in JSON?

No. Standard JSON has no comments. JSONC and JSON5 add them, but strict parsers reject them. Auto-fix in the editor strips // and /* */ comments for you.

Are trailing commas valid?

No. A comma after the last array element or object property is invalid, even though JavaScript allows it.

Can I use single quotes?

No. Strings and keys must use double quotes.

What's the difference between RFC 8259 and ECMA-404?

Same grammar; RFC 8259 adds interoperability rules (UTF-8 required, duplicate-key and precision warnings). Syntactically, a document valid under one is valid under the other.

Does JSON support big numbers?

The grammar allows them, but typical parsers lose precision above 253 − 1. Use strings or a lossless parser for big integers.

Is NaN or Infinity valid?

No. JSON numbers must be finite. Use null or a string convention.

Try it yourself → Paste your JSON into the free online editor: instant validation with line-precise errors, one-click Auto-fix, tree/table editing, diff, and CSV/YAML export. Nothing is uploaded; it all runs in your browser.