← Back to Library Web Development Beginner 6 min read

What Is JSON? The Universal Web Data Format Explained

JSON (JavaScript Object Notation) is a lightweight, human-readable, and machine-parsable text format used worldwide for storing and transmitting structured data between web browsers and servers.

💡 Plain-English Analogy

JSON is essentially a standardized text format that represents lists and labelled attributes. It looks very similar to how you would write notes in a structured bulleted notepad, using key-value pairs like "name": "Alice" and "age": 25.

⚙️ Architecture & Under the Hood

JSON is defined by ECMA-404 and RFC 8259. It is strictly text-based and language-agnostic, supporting six primitive types: string, number, boolean, null, object, and array. JSON forbids trailing commas, comments, and unquoted keys, ensuring deterministic cross-language serialization.

JSON Syntax & Supported Data Types

JSON structures are composed of two core containers: objects (curly braces {}) and arrays (square brackets []).

Keys in JSON MUST always be enclosed in double quotes. Single quotes or backticks will throw syntax errors.

  • Strings: Must use double quotes ("hello").
  • Numbers: Plain integer or floating point (42, 3.1415), without quotes.
  • Booleans: true or false (all lowercase).
  • Null: Denotes absence of value (null).
  • Forbidden: Functions, undefined, dates (stored as ISO strings), and comments.
{
  "developer": "Pratyush",
  "experienceYears": 8,
  "isActive": true,
  "specialties": ["TypeScript", "Distributed Systems", "WebGL"],
  "preferences": {
    "editor": "VS Code",
    "theme": "Dark",
    "tabSize": 2
  },
  "remoteWorkLocation": null
}

Parsing and Serializing in JavaScript & Python

Parsing turns a raw JSON string into an in-memory data object. Stringifying turns an in-memory object into a JSON text string.

// 1. Parsing JSON string into JavaScript Object
const jsonText = '{"status":"ok","itemsCount":3}';
const parsedData = JSON.parse(jsonText);
console.log(parsedData.status); // "ok"

// 2. Stringifying JavaScript Object into formatted JSON
const userSession = { user: "john_dev", role: "admin" };
const serialized = JSON.stringify(userSession, null, 2);
console.log(serialized);

Frequently Asked Questions

Why does JSON not support comments?

Douglas Crockford, the creator of JSON, intentionally removed comments to prevent developers from using comments to hold parsing directives, which would break cross-platform interoperability.

How should dates be stored in JSON?

Dates should be stored as ISO 8601 formatted strings (e.g. "2026-03-21T14:30:00.000Z") or as Unix epoch timestamps in milliseconds.