What Is JSON? A Complete Guide for Developers
Learn what JSON is, how it works, its syntax rules and data types, how it compares to XML and YAML, and why JSON became the default format for APIs, configs, and AI applications.
JSON (JavaScript Object Notation) is the lingua franca of modern software. From REST APIs to Kubernetes configs to LLM structured outputs, JSON carries structured data between systems that may not share a single programming language. This guide explains what JSON is, where it came from, the exact rules that keep it valid, the data types it supports, and how it stacks up against XML and YAML — so you can read, write, and debug it with confidence.
JSON in one sentence
JSON is a lightweight, text-based format for serializing structured data — objects, arrays, numbers, strings, booleans, and null. It was designed to be easy for humans to read and write, and easy for machines to parse and generate. Because it is just text, JSON travels well: it can be sent over HTTP, written to a file, stored in a database column, or pasted into a chat message, and any system with a JSON parser can turn it back into native data structures.
The example below uses every value type JSON supports. Notice that the structure is self-describing — you can tell what each field means without a separate schema or documentation.
{
"name": "Ada Lovelace",
"age": 36,
"active": true,
"roles": ["admin", "author"],
"address": { "city": "London", "zip": null }
}A short history of JSON
JSON was specified by Douglas Crockford in the early 2000s, derived from the object literal syntax of JavaScript. It deliberately avoided the verbosity of XML, which dominated web data interchange at the time. Despite borrowing JavaScript's notation, JSON is language-independent — the conventions it uses are familiar to programmers of the C family of languages, including C, C++, C#, Java, Python, and many others.
JSON is now an international standard, defined by ECMA-404 and IETF RFC 8259. Those specifications are intentionally small, which is a large part of why JSON parsers exist for virtually every language and why two independent implementations rarely disagree about what a document means. The official media type is application/json, and the conventional file extension is .json.
Core syntax rules
JSON's grammar is strict and small, which is what makes it predictable. A handful of rules cover almost everything you will ever need to remember, and most invalid JSON breaks one of them.
- Objects use curly braces { } and contain comma-separated key-value pairs.
- Arrays use square brackets [ ] and contain an ordered, comma-separated list of values.
- Keys must be double-quoted strings.
- Strings must use double quotes — never single quotes.
- No trailing comma is allowed after the last element of an object or array.
- Comments are not part of the JSON specification.
- Whitespace between tokens is ignored, so formatting is purely for human readability.
The six JSON data types
Every value in a JSON document is one of six types. Three are scalar (a single value) and two are containers that can nest other values to any depth, plus the special null.
{
"string": "hello\nworld",
"number": 42.5,
"boolean": false,
"nothing": null,
"object": { "nested": true },
"array": [1, "two", false, null]
}- String — Unicode text in double quotes, with backslash escapes such as \n, \t, \", and \uXXXX.
- Number — an integer or floating-point value; JSON does not distinguish int from float, and it has no NaN or Infinity.
- Boolean — the literals true or false, lowercase.
- null — an explicit 'no value' marker, distinct from a missing key.
- Object — an unordered collection of string keys mapped to values.
- Array — an ordered sequence of values that can mix types.
How JSON maps to code
The reason JSON feels effortless in most languages is that its types map cleanly onto native data structures. A JSON object becomes a dictionary, map, or plain object; a JSON array becomes a list or array. Parsing turns text into those structures, and serializing turns them back into text.
In JavaScript the built-in JSON object handles both directions. In Python the json module does the same with json.loads and json.dumps. Go uses encoding/json with struct tags, Java commonly uses Jackson or Gson, and every other mainstream language ships or has a de facto standard library. Because the format is identical everywhere, a payload produced in Python can be consumed in Go without translation.
const obj = JSON.parse('{"active": true}'); // text -> object
const text = JSON.stringify(obj); // object -> textWhere JSON is used
JSON is everywhere structured data needs to move or be stored. REST and GraphQL APIs use it for request and response bodies. Configuration files such as package.json, tsconfig.json, and cloud service definitions use it. NoSQL databases like MongoDB store JSON-shaped documents, and relational databases like PostgreSQL offer native JSON and JSONB column types. Log pipelines emit JSON lines so events stay machine-parseable.
More recently, JSON has become the interface language of AI. Large language models emit JSON for tool calls, function arguments, and structured outputs, and frameworks validate that JSON against a schema before acting on it. Whether you work on front-end, back-end, data, or AI, JSON is part of the daily workflow.
JSON vs XML vs YAML
JSON is not the only structured data format, and each alternative has a niche. XML excels at document markup, mixed content, and enterprise integrations with heavy schemas and namespaces, but it is verbose and slower to parse. YAML is a superset-style format popular for human-edited configuration — Kubernetes manifests, GitHub Actions workflows — because it supports comments and uses indentation instead of braces, at the cost of subtle whitespace pitfalls.
JSON wins for machine-to-machine interchange because parsers are ubiquitous, the grammar is unambiguous, and payloads are compact and predictable. A practical rule of thumb: use JSON for APIs and data exchange, YAML for configuration humans edit by hand, and XML only when an existing system or standard requires it.
Working with JSON in practice
Reading raw JSON from an API or a log file is far easier once it is formatted. A JSON Formatter indents and line-breaks a dense payload so the nesting becomes visible, and a JSON Validator pinpoints the exact line and column of any syntax error. For sustained editing with live feedback, a JSON Editor combines syntax highlighting, validation, and format-on-demand in one place.
All of these tools on JsonDrift run entirely in your browser, so sensitive payloads never leave your machine. That privacy-first model matters when the JSON you are debugging contains tokens, customer records, or anything you would not paste into a third-party server.
Frequently asked questions
Is JSON only for JavaScript?
No. Despite the name, JSON is language-neutral. Every major programming language ships or has a de facto standard JSON parser, and a document produced in one language can be consumed in any other without modification.
Can JSON have comments?
Standard JSON does not allow comments — they will cause a parse error. If you need comments in a config file, use JSONC or JSON5 in editors that support them, or strip the comments before parsing. Many teams use YAML for comment-friendly configuration instead.
What is the difference between null and a missing key in JSON?
null is an explicit value that says 'this field exists and is intentionally empty'. A missing key means the field is absent entirely. Many APIs treat the two differently — for example, null might clear a value while an absent key leaves it unchanged.
Does JSON support dates?
JSON has no native date type. Dates are conventionally stored as strings in ISO 8601 format, such as "2026-06-14T10:30:00Z", and parsed into a date object by the receiving code. Some systems also use a Unix timestamp number.
What is the difference between JSON and a JavaScript object?
JSON is a text format — a string. A JavaScript object is an in-memory data structure. JSON.parse converts JSON text into an object, and JSON.stringify converts an object back into JSON text. JSON also has stricter rules: keys must be quoted, only double quotes are allowed, and functions, undefined, and comments are not permitted.
Is JSON case-sensitive?
Yes. Object keys are case-sensitive, so "name" and "Name" are different keys. The literals true, false, and null must also be lowercase — any other casing is invalid.
Related tools
Try these tools
JSON Validator
Validate JSON instantly with precise, human-readable error messages and line numbers.
JSON Formatter & Beautifier
Format, prettify, and beautify messy JSON with configurable indentation and key sorting.
JSON Editor
Write, edit, format, minify, and validate JSON in a fast full-screen or embedded editor.
JSON Viewer & Tree Explorer
Explore JSON with an interactive collapsible tree view.