What Is JSON? A Complete Guide

JSON (JavaScript Object Notation) is a lightweight data format for storing and exchanging data. Here's everything you need to know.

The Basics

Full name

JavaScript Object Notation

Pronunciation

"JAY-son" (like the name Jason)

Created by

Douglas Crockford, early 2000s

Standard

RFC 8259

Language support

Python, Java, Go, Ruby, C#, and every major language

File extension

.json

JSON Syntax Rules

  1. 1

    Data is in key/value pairs — keys must be double-quoted strings

  2. 2

    Data is separated by commas

  3. 3

    Objects use curly braces {}

  4. 4

    Arrays use square brackets []

  5. 5

    No trailing commas allowed

  6. 6

    No comments allowed (use "_comment" key as workaround)

Valid example

{
  "name": "Alice",
  "age": 30,
  "active": true,
  "score": 9.5,
  "address": null,
  "tags": ["dev", "admin"]
}

JSON Data Types

String

"hello"

Always double quotes

Number

42 / 3.14

Integer or float, no quotes

Boolean

true / false

Lowercase only

Null

null

Represents empty/unknown

Array

[1, "a", true]

Ordered list, mixed types OK

Object

{"key": "val"}

Key-value pairs, keys must be strings

JSON vs Other Formats

JSON vs CSV

JSON supports nested data and types; CSV is simpler for tabular data.

Full comparison

JSON vs XML

JSON is more compact; XML supports attributes and comments.

Full comparison

JSON vs YAML

YAML is more human-friendly for config; JSON is better for APIs.

Common JSON Mistakes

DON'T

Use single quotes — {'name': 'Alice'} ❌

DON'T

Leave trailing commas — {"a": 1,} ❌

DON'T

Add comments — // this fails ❌

DON'T

Use undefined — not a valid JSON value ❌

DO

Use double quotes for all keys and strings ✓

DO

Validate with a JSON formatter before using ✓

JSON Special Values

Booleans

true and false — lowercase only. True, False, and TRUE are all invalid JSON.

Null

null represents an absent or unknown value. It is distinct from 0, false, and "" — each has a different semantic meaning.

Dates

JSON has no native date type. Common approaches: ISO 8601 string, Unix timestamp, or a custom format. Always agree on a format with your API.

ISO 8601 (recommended)

"2024-01-15T10:30:00Z"

Unix timestamp

1705312200

Custom format

"2024-01-15"

Escape Characters

Special characters inside JSON strings must be escaped with a backslash.

SequenceMeaning
\"double quote
\\backslash
\nnewline
\ttab
\/forward slash (optional)

Work with JSON — Free Online Tools

Validate and format your JSON instantly

Free, browser-based, no sign-up. Your data never leaves your device.