What is JSON?
JSON is a lightweight, language-independent format for structured data. Learn what it is, where it came from, and why it replaced XML for most APIs.
Try It Now
Put this into practice with OpenFormatter's free tools — no signup, 100% client-side.
Specification: JSON is often called "a strict subset of JavaScript," but RFC 8259 notes an exception: the Unicode line and paragraph separators U+2028 and U+2029 are legal inside JSON strings, yet were historically invalid inside JavaScript string literals. TC39 closed this gap for ECMAScript in 2019, but older JavaScript engines can still reject JSON that a JSON parser accepts.
Definition
JSON (JavaScript Object Notation) is a lightweight, text-based format for representing structured data as name/value pairs and ordered lists of values. It grew out of JavaScript's own object literal syntax, but it's deliberately language-independent — every mainstream programming language can parse and generate it, which is why it became the default format for REST APIs, configuration files, and data interchange between systems that otherwise share nothing.
The format was specified by Douglas Crockford, who published the first formal specification as RFC 4627 in July 2006 under the json.org project. That RFC was later obsoleted by RFC 7159 and then by RFC 8259 (December 2017, edited by Tim Bray), which is the current IETF standard. A parallel specification, ECMA-404, defines the same grammar through Ecma International's standards process, and the two documents commit to staying aligned with each other.
Examples
A minimal, valid JSON object.
{
"name": "Ada Lovelace",
"occupation": "Mathematician",
"active": true,
"notes": null
}The same data expressed in XML, for comparison. JSON needs no closing tags, and its objects and arrays map directly onto data structures most languages already have built in.
<person>
<name>Ada Lovelace</name>
<occupation>Mathematician</occupation>
<active>true</active>
<notes/>
</person>Official Specification
Related References
FAQs
Why is JSON more popular than XML for APIs?
JSON is more compact than XML — it has no closing tags — and its two core structures (objects and arrays) map directly onto the data types most programming languages already have built in, so there's no separate parsing model to learn. XML remains stronger for document-centric use cases with mixed content, namespaces, and formal schema validation (XSD), but for the request/response bodies of REST APIs, JSON's simplicity became the practical default as SOAP and XML-based APIs fell out of favor through the 2010s.
Should I use JSON or YAML?
Both are reasonable choices for config files; the right one depends on what you're optimizing for. YAML supports comments and reads more like plain text, which developers often prefer for hand-edited configuration. But YAML's indentation-based syntax and implicit type conversion have real, well-documented failure modes — for example, YAML 1.1 parsers can silently convert an unquoted NO or on into a boolean instead of a string (sometimes called the "Norway problem"). JSON has a much smaller, stricter grammar with far fewer surprises, which is why it remains the standard for machine-to-machine data interchange even where YAML is preferred for human-edited files.