Skip to content

What is JSON?

Web Development, explained by the engineers who build it. Definition, how it works, use cases and common questions.

JSON definition

JSON (JavaScript Object Notation) is a lightweight, text-based format for representing structured data as objects of key and value pairs and ordered arrays. It is easy for humans to read and for almost every programming language to parse, which has made it the default format for web APIs, configuration files and data exchanged between browsers, servers and apps.

JSON syntax and data types

A JSON document is built from six data types: strings in double quotes, numbers, booleans (true or false), null, arrays in square brackets and objects in curly braces. Objects hold key and value pairs where every key is a string. An order might look like {"id": 123, "paid": true, "items": [{"sku": "A1", "qty": 2}], "note": null}, and values can nest to any depth.

JSON is strict. Keys must use double quotes, trailing commas are not allowed and comments are not part of the standard. Those rules make parsing fast and predictable, but they also cause most JSON errors. Paste a payload into our JSON formatter to validate it and find the exact line that breaks.

Where JSON is used

Because JSON is plain text, it compresses well with gzip or Brotli over HTTP, but it is still larger and slower to process than binary formats such as Protocol Buffers or MessagePack. High-volume internal services sometimes switch to those, while public APIs stay with JSON for readability and broad tool support. Common uses include:

  • Web and mobile APIs: request and response bodies for most REST APIs
  • Configuration: package.json in JavaScript projects, tsconfig.json and many cloud and editor settings
  • Databases: document stores such as MongoDB and JSON columns in PostgreSQL
  • Logs and events: structured logs and event streams that tools can search and aggregate
  • AI: structured outputs and tool calls from language models are typically JSON

JSON vs XML vs YAML

XML predates JSON for data exchange and supports attributes, namespaces and mature schemas, but it is more verbose and harder to map to native data structures. YAML is a superset of JSON designed for humans, with indentation instead of braces and support for comments, which is why Kubernetes and many CI tools use it for configuration.

JSON sits in the middle: less expressive than XML and less pleasant to hand-edit than YAML, but simple, fast to parse and supported everywhere. For data moving between programs, especially over HTTP, that simplicity usually wins, while humans maintaining large configuration files often prefer YAML.

Validating JSON and common pitfalls

Valid syntax does not mean valid data. JSON Schema lets you describe required fields, types, formats and allowed values, and validate payloads at API boundaries so bad data is rejected early with a clear error. In TypeScript projects the same contract can produce types; our JSON to TypeScript tool turns a sample payload into interfaces in seconds.

Watch numbers and dates. JSON has no separate integer and decimal types, and JavaScript loses precision on integers above 2^53, so large IDs and money amounts are safer as strings or integer minor units such as cents. Dates have no native type either, so agree on ISO 8601 strings with explicit time zones. And never parse JSON with eval or string manipulation; use the built-in parser, such as JSON.parse, which rejects malformed input safely.

JSON: common questions

Something else on your mind? Ask a consultant and get a reply within one business day.

What does JSON stand for?

JSON stands for JavaScript Object Notation. It was derived from JavaScript object literal syntax, which is why it looks familiar to web developers, but it is language-independent. Parsers exist for virtually every programming language, and the format is standardized in ECMA-404 and RFC 8259.

Is JSON better than XML?

For most web APIs, yes, because it is smaller, faster to parse and maps directly to objects and arrays in code. XML still suits document-centric data, mixed content and industries with established XML standards, such as parts of banking, healthcare and publishing. The best choice is often whatever your partners already use.

Can JSON have comments?

Standard JSON does not allow comments, and strict parsers reject them. Some tools accept JSON with comments, often called JSONC, for files such as VS Code settings or tsconfig.json. If you need comments in hand-edited configuration, YAML or JSONC may suit better than plain JSON.

Keep exploring the web development glossary

Need JSON in your product?

A solutions consultant replies within one business day with next steps, a rough estimate and a suggested team.