JSON · July 10, 2026 · 9 min

What is JSON? Definition, Syntax, and Examples

Understand what JSON is, how it works, and why it became the default format for APIs and configuration.

Definition and History

JSON stands for JavaScript Object Notation. Douglas Crockford specified and popularized it in the early 2000s as a lightweight alternative to XML for data interchange. Despite the name, JSON is language-independent — every major programming language includes libraries to read and write it. Today JSON is the default format for REST APIs, configuration files, NoSQL databases, and message queues.

JSON became dominant because it maps naturally to native data structures. A JSON object becomes a JavaScript object, a Python dictionary, a Java Map, or a Go struct. XML requires more ceremony: namespaces, attributes, and mixed content add power but also complexity. For most web and mobile applications, JSON's simplicity wins.

The official standard is RFC 8259, which defines strict syntax rules. JSON is a subset of JavaScript object literal syntax, but not every JavaScript object can be serialized to JSON — functions, `undefined`, and `Symbol` values are excluded. Understanding these boundaries prevents confusion when moving data between JSON and code.

JSON Data Types

JSON supports exactly six data types: object, array, string, number, boolean, and null. Objects are unordered collections of key-value pairs enclosed in curly braces. Keys must be strings enclosed in double quotes. Arrays are ordered lists enclosed in square brackets. Strings use double quotes and support Unicode escape sequences like `\u0041` for the letter A.

Numbers in JSON have no leading zeros (except for 0 itself) and no trailing decimal point without digits. Scientific notation is allowed: `1.5e10` is valid. Booleans are lowercase `true` or `false`. Null represents an intentional absence of value — distinct from an empty string or zero.

A simple example: `{"name": "Alice", "age": 30, "active": true, "tags": ["admin", "user"]}`. Paste this into the JSON Formatter to see it with proper indentation, or open it in the JSON Viewer to explore the tree structure interactively.

JSON Syntax Rules

Whitespace (spaces, tabs, line breaks) between tokens is allowed and ignored by parsers. This means you can minify JSON to a single line for transmission or format it with indentation for readability — the parsed result is identical. Commas separate elements in objects and arrays, but a trailing comma after the last element is forbidden.

Strings must escape certain characters with a backslash: double quotes (`"`), backslashes (`\`), and control characters. Common escapes include `\n` for newline, `\t` for tab, and `\uXXXX` for Unicode code points. Our JSON escape characters guide covers every escape sequence with examples.

Comments are not part of the JSON specification. If you need comments in configuration files, consider JSON5 (a superset with comments and trailing commas) or use a format like YAML for human-edited configs. For strict JSON, use the JSON Validator to confirm your file has no comments or other non-standard syntax.

JSON vs Other Formats

JSON competes primarily with XML, YAML, Protocol Buffers, and MessagePack. XML remains strong in enterprise integrations, document markup, and systems requiring XML Schema validation. YAML is popular for Kubernetes and CI/CD configs because it supports comments and is more readable for nested structures. Protocol Buffers and MessagePack prioritize compact binary encoding over human readability.

For web APIs, JSON is the clear default. It is text-based (easy to debug), universally supported, and works well with HTTP. Our detailed comparison in JSON vs XML walks through when each format still makes sense in 2026.

When you receive XML from a legacy system, the XML Formatter helps make it readable. When you need to validate YAML configs before deployment, use the YAML Validator to catch indentation and syntax errors early.

Where JSON Is Used

REST APIs return JSON in response bodies and often accept JSON in POST and PUT requests. GraphQL responses are JSON. Webhook payloads from Stripe, GitHub, Slack, and countless other services arrive as JSON. Browser localStorage and sessionStorage store strings, and applications frequently serialize objects to JSON before saving.

Configuration files for tools like package.json, tsconfig.json, and .eslintrc.json use JSON. Cloud services (AWS, GCP, Azure) expose JSON-based APIs for infrastructure management. Databases like MongoDB store documents that map closely to JSON, and Elasticsearch indexes JSON documents for full-text search.

JWT tokens encode their header and payload as Base64URL-encoded JSON. Use the JWT Decoder to inspect token contents during authentication debugging — but remember that decoding is not verification. Our How JWT Works article explains the full token lifecycle.

Working with JSON as a Developer

Start by validating any unfamiliar JSON before using it in code. Paste it into the JSON Validator to get precise error locations. Format messy payloads with the JSON Formatter to make structure visible. For deep exploration, the JSON Viewer provides collapsible tree navigation and search.

Learn parsing in your language of choice with our How to Parse JSON guide, which covers JavaScript, Python, and other ecosystems. For production pipelines, combine manual inspection tools with automated JSON Schema validation in your CI/CD workflow.

JSON looks simple on the surface, but edge cases — duplicate keys, deep nesting, large numbers losing precision in JavaScript — can cause production bugs. Treat JSON as a contract between systems: document your schemas, validate inputs, and use the right tools at each stage of development.

Related Tools

Related Articles