$devtoolkit.sh/glossary/what-is-json

What is JSON? — JavaScript Object Notation Explained

Definition

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. It is derived from JavaScript object syntax but is language-independent and is supported natively in virtually every programming language. JSON is the dominant format for web APIs, configuration files, and data storage in NoSQL databases.

How It Works

A JSON document is built from two structures: objects (unordered key-value pairs wrapped in {}) and arrays (ordered sequences of values wrapped in []). Values can be strings (double-quoted), numbers, booleans (true or false), null, other objects, or other arrays. Keys must be strings. Unlike JavaScript, JSON does not support comments, trailing commas, or undefined values. The JSON.parse() function converts a JSON string into a native data structure, and JSON.stringify() converts a data structure back into a JSON string.

Common Use Cases

  • Sending and receiving data between web browsers and REST APIs
  • Storing structured configuration in package.json, tsconfig.json, and similar files
  • Persisting documents in NoSQL databases like MongoDB and Firestore
  • Exchanging data between microservices over HTTP
  • Encoding JWT payloads and other token claims

Example

{
  "user": {
    "id": 42,
    "name": "Alice",
    "active": true,
    "roles": ["admin", "editor"],
    "profile": null
  }
}

Related Tools

FAQ

Can JSON have comments?
Standard JSON does not support comments. This is a deliberate design decision to keep parsing simple. If you need comments in configuration files, consider JSONC (JSON with Comments, used by VS Code) or YAML, which natively supports # comments.
What is the difference between null and undefined in JSON?
JSON supports null as an explicit empty value. JavaScript's undefined has no JSON equivalent — JSON.stringify() omits object properties with undefined values entirely. Always use null when you need to explicitly represent "no value" in a JSON payload.
Why must JSON keys be quoted strings?
Unlike JavaScript object literals, JSON requires all keys to be double-quoted strings. This strict rule makes JSON unambiguous and easy to parse with a simple grammar, without needing to distinguish keywords from identifiers.

Related Terms

/glossary/what-is-jsonv1.0.0