What is JSON?

JSON (JavaScript Object Notation) is the standard lightweight data format used by web APIs, configuration files, and data storage. It is readable by humans and parseable by virtually every programming language.

Definition

JSON is a text-based format for representing structured data as key-value pairs and ordered lists. It was derived from JavaScript object syntax but is completely language-independent.

JSON Data Types

  • String — text in double quotes: "hello"
  • Number — integer or decimal: 42, 3.14
  • Booleantrue or false
  • Nullnull (the absence of a value)
  • Array — ordered list in square brackets: [1, 2, 3]
  • Object — key-value pairs in curly braces: {"name": "Alice", "age": 30}

Common JSON Errors

  • Trailing commas after the last item in an array or object
  • Single quotes instead of double quotes around strings or keys
  • Unquoted keys (valid in JavaScript but not in JSON)
  • Comments (JSON does not support // or /* */)
  • Undefined values (undefined is not a valid JSON value)

JSON vs JavaScript Objects

JSON requires double quotes around keys, forbids trailing commas and comments, and does not support undefined, functions, or dates as native types. JavaScript objects are more permissive.

Format, validate, and inspect JSON in your browser: Open JSON Formatter →

Frequently Asked Questions

What does "invalid JSON" mean?

It means the text does not conform to the JSON specification — usually a missing quote, a trailing comma, or a comment. A JSON formatter will highlight the exact line with the error.

What is the difference between JSON and YAML?

Both are data serialisation formats. YAML is designed to be more human-readable (uses indentation instead of braces), while JSON is more widely supported and faster to parse. YAML is a superset of JSON.

What is "pretty printing" JSON?

Pretty printing adds indentation and line breaks to make minified JSON readable. A minified JSON string is compact (suitable for network transfer); a pretty-printed version is indented (easier to read and debug).

Related Terms

  • JWT — JSON Web Tokens encode claims as JSON.
  • YAML — A more human-readable alternative to JSON for config files.
  • CSV — A simpler tabular format compared to nested JSON.