What Is JSON? JavaScript Object Notation Explained

JSON (JavaScript Object Notation) is the most widely used data format on the internet. This guide explains what JSON is, how to read and write it, and when to use it.

Published by JSONFormatter.site · May 2026

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate. Despite its name, JSON is language-independent — it is used in virtually every programming language and platform, not just JavaScript.

JSON was invented by Douglas Crockford in the early 2000s and was standardized as ECMA-404 and RFC 8259. It became the dominant format for web APIs, replacing XML due to its significantly simpler syntax and smaller file size.

Example: A simple JSON object

{
  "name": "Alice",
  "age": 30,
  "isStudent": false,
  "courses": ["Math", "Physics"],
  "address": {
    "city": "New York",
    "country": "USA"
  }
}

JSON Syntax Rules

JSON has a small set of strict syntax rules. Violating any of these rules results in invalid JSON that cannot be parsed:

  • Keys must be strings — All object keys must be wrapped in double quotes: "key", not key or 'key'.
  • Strings use double quotes only — Single quotes are not valid in JSON.
  • No trailing commas — The last item in an array or object must not have a trailing comma.
  • No comments — Standard JSON does not support // or /* */ comments.
  • No undefinedundefined is not a valid JSON value. Use null instead.

JSON Data Types

JSON supports exactly six data types:

TypeExampleDescription
String"Hello, World!"Text wrapped in double quotes
Number42 or 3.14Integer or floating-point number
Booleantrue or falseLogical true/false value
Array[1, "two", true]Ordered list of values in square brackets
Object{"key": "value"}Key-value pairs in curly braces
NullnullRepresents absence of a value

JSON vs XML

Before JSON became dominant, XML was the standard format for data interchange. Here is how the same data looks in both formats:

JSON

{
  "user": {
    "name": "Alice",
    "age": 30
  }
}

XML (same data)

<user>
  <name>Alice</name>
  <age>30</age>
</user>

JSON is typically shorter, easier to read, and faster to parse. XML supports attributes, namespaces, and comments, making it more suitable for complex document formats. Use our JSON to XML converter to transform between the two.

Where is JSON Used?

  • REST APIs — JSON is the standard response format for HTTP APIs. When you make an API call, the response is almost always JSON.
  • Configuration files — package.json, tsconfig.json, .eslintrc, and many other developer tool configs use JSON.
  • Web storage — localStorage and sessionStorage in browsers store data as JSON strings.
  • Databases — MongoDB, PostgreSQL (JSONB), and many NoSQL databases store and query JSON natively.
  • Data exchange — JSON is the lingua franca for data exchange between services, microservices, and third-party integrations.

Common JSON Errors Beginners Make

  • Using single quotes{'name': 'Alice'} is invalid. Use double quotes.
  • Trailing commas{"a": 1, "b": 2,} is invalid. Remove the last comma.
  • Unquoted keys{name: "Alice"} is invalid. Wrap keys in double quotes.
  • Using undefined — Replace undefined with null.

Use our JSON Fixer to automatically correct these errors, or the JSON Formatter & Validator to identify exactly which line has an error.

Try Our Free JSON Formatter

Paste any JSON to format, validate, and beautify it instantly — no signup, 100% private.

Open JSON Formatter