Utility Hub
DeveloperUpdated

What Is JSON?

A clear, practical introduction to JSON — its structure, data types, common mistakes, and why it became the default format for web APIs.

JSONDeveloper ToolsData Formats

What does JSON stand for?

JSON stands for JavaScript Object Notation. Despite the name, it is completely language-independent — every major programming language can read and write JSON natively or through a well-maintained library.

JSON was specified by Douglas Crockford in the early 2000s as a lightweight alternative to XML for transmitting data between a server and a browser. It succeeded wildly: today JSON is the standard format for web APIs, configuration files, and structured data interchange.

Basic structure

A JSON document is text — a sequence of characters that follows a strict grammar. At the top level it must be either:

Everything else in JSON is a value, and values can be nested arbitrarily deep.

Data types

JSON has exactly six value types.

Objects

An object is a collection of key/value pairs. Keys must be double-quoted strings. Values can be any JSON type.

{
  "username": "alice",
  "age": 30,
  "active": true
}

Arrays

An array is an ordered list. Elements can be any value type and do not need to share a type.

["red", "green", "blue"]
[1, "two", true, null, { "nested": "object" }]

Strings

Strings must be wrapped in double quotes — single quotes are not valid JSON. A handful of characters must be backslash-escaped:

CharacterEscape sequence
Double quote\"
Backslash\\
Newline\n
Tab\t

Numbers

JSON numbers can be integers or floating-point. There is no separate int / float distinction.

42
3.14159
-7
1.5e10

JSON does not support Infinity, -Infinity, or NaN.

Booleans

Exactly two values: true and false. Both are lowercase.

null

The single value null represents the intentional absence of a value. It is not the same as an empty string "" or the number 0.

A realistic example

Here is a JSON payload a server might return for a user profile:

{
  "id": 1042,
  "username": "alice_dev",
  "email": "[email protected]",
  "isPremium": false,
  "bio": null,
  "tags": ["javascript", "open-source"],
  "address": {
    "city": "London",
    "country": "GB"
  },
  "createdAt": "2024-03-15T09:41:00Z"
}

JSON has no native date type — dates are represented as strings. The ISO 8601 format ("2024-03-15T09:41:00Z") is the widely adopted convention.

Common JSON mistakes

Trailing commas — the last item in an object or array must not have a trailing comma:

// ✗ Invalid
{
  "name": "Alice",
  "age": 30,
}

// ✓ Valid
{
  "name": "Alice",
  "age": 30
}

Single-quoted strings — valid JavaScript, but not valid JSON:

// ✗ Invalid
{ 'name': 'Alice' }

// ✓ Valid
{ "name": "Alice" }

Unquoted keys — another habit from JavaScript object literals that breaks JSON:

// ✗ Invalid
{ name: "Alice" }

// ✓ Valid
{ "name": "Alice" }

Comments — JSON does not support comments. If you need them in config files, look at JSONC or JSON5, which are separate (non-standard) formats.

Formatted vs minified JSON

Production JSON is often transmitted without whitespace to reduce payload size:

{"id":1042,"username":"alice_dev","isPremium":false,"tags":["javascript","open-source"]}

This is valid but nearly impossible to read. A JSON formatter re-adds indentation and line breaks. A JSON validator checks the grammar and reports errors precisely. Both run entirely in your browser.

Tips for working with JSON