JSON
| Standard | |
|---|---|
![]() Image placeholderPlace the file shown below in the assets/articles folder json.webp | |
| Defined in | RFC 8259, ECMA-404 |
| Created by | Douglas Crockford |
| Media type | application/json |
JSON (JavaScript Object Notation) represents data as objects, arrays, strings, numbers, booleans and null. It is defined in RFC 8259 and ECMA-404.
Problem it solves
Douglas Crockford popularised the format in the early 2000s as a simpler alternative to XML for web applications.
{
"name": "WikiTech",
"founded": 2026,
"tags": ["tech", "software"],
"ads": false
}Specification summary
An object is a set of key-value pairs in braces, keys are strings, and values can nest. Text must be encoded in UTF-8. Comments and trailing commas are not allowed.
Adoption
JSON is the common format for web APIs and configuration. It has no date type and its number handling is implementation-dependent for large values.
Status and versioning
RFC 8259 (December 2017) is the current IETF specification.
Data model and syntax
JSON represents data using a small set of value types: objects, arrays, strings, numbers, booleans and null. An object is a collection of name-value pairs, while an array is an ordered list. Values can be nested, allowing a document to represent trees such as a user profile containing an address and a list of preferences. The format deliberately excludes executable functions, comments and several features of JavaScript syntax that would make documents harder to exchange consistently.
Strings use double quotation marks and support defined escape sequences for quotation marks, reverse solidus characters and control characters. A JSON number follows a grammar that supports integers, fractions and exponents, but JSON does not define a separate integer type or a decimal type with fixed precision. Applications that require exact monetary arithmetic or very large integers should choose a representation and parsing strategy that avoids precision loss.
Serialization and parsing
Serialization converts an in-memory value into JSON text. Parsing performs the reverse operation, creating values in the receiving language. This makes JSON useful at API boundaries, in configuration files, in message queues and in local data storage. Because JSON is text-based, it can be inspected with ordinary developer tools and transmitted over many kinds of network connection.
The same JSON document can be interpreted differently by different programming languages. For example, some languages distinguish integers and floating-point values, while others represent all JSON numbers through one numeric type. Object key ordering is not a reliable way to express meaning unless a separate convention guarantees it. Applications should validate types and required fields rather than relying on incidental formatting.
JSON in web APIs
Many HTTP APIs use the media type application/json. A client sends a request body containing JSON and identifies its format through the Content-Type header. A server can respond with JSON and an appropriate status code. This convention is simple, but a JSON document alone does not specify the API's authentication, error model, pagination, versioning or compatibility rules. Those details belong to the API contract.
Schema languages can describe the expected structure of JSON documents. JSON Schema, for example, can express required properties, allowed types, value constraints and nested object shapes. Validation helps detect malformed or unexpected input before it reaches application logic. It should be combined with appropriate limits on document size, nesting and processing time when the data comes from untrusted sources.
Security considerations
JSON is a data format, not a security boundary. Applications must not assume that parsed values are trustworthy. A server should validate user input, enforce authorisation independently of fields in a request, and avoid passing untrusted strings into SQL queries, shell commands or HTML contexts without the relevant escaping or parameterisation. Some older JavaScript patterns treated JSON as executable code; modern applications should use a proper JSON parser rather than evaluating text.
Large or deeply nested inputs can also consume memory and CPU. Services that accept JSON should set sensible request limits and handle parse errors safely. Logging should avoid recording secrets or personal data merely because they appear in a request body.
Strengths and limitations
JSON is compact, language-independent and easy to use with web technologies. Its limited data model makes it broadly interoperable. It does not natively represent comments, binary data, dates, references or cyclic object graphs. Applications commonly encode dates as strings and binary data as Base64, but those conventions require agreement between producer and consumer.
The simplicity of JSON is its main advantage. A well-designed API documents the meaning of each field, required and optional properties, number ranges and versioning expectations. Without that shared contract, two valid JSON documents can still express incompatible assumptions. JSON provides a common syntax; software design supplies the semantics.
When another data format is useful
JSON is a good default for many web APIs, but it is not ideal for every exchange. Binary formats can be more compact for high-volume data, while schemas with stronger type systems can make contracts easier to validate. Formats such as Protocol Buffers, MessagePack and CBOR address different performance or interoperability needs. Choosing between them depends on the environment, debugging requirements, compatibility guarantees and the cost of parsing. JSON remains common because it is readable and well supported, not because it is always the smallest or fastest representation.
Editorial connections and engineering implications
Data validation and number representation
A JSON parser verifies syntax, not application correctness. A document can be valid JSON while omitting a required field, using an unexpected value or violating a business rule. Reliable APIs separate parsing, schema validation, domain validation and authorisation. The distinction is important because untrusted input should not reach sensitive application logic merely because it was successfully decoded.
JSON also leaves application-specific representations to the protocol designer. Dates, currency amounts, binary data and identifiers need explicit conventions. JavaScript represents ordinary numbers with IEEE 754 double precision, which cannot exactly represent every large integer. APIs that exchange identifiers or exact decimal values should choose a representation that preserves the required precision. JSON is popular because it is readable and widely supported, not because it is optimal for every data pipeline. It connects naturally to JavaScript, HTTP and UTF-8.
See also
- JavaScript – The programming language that powers interactive web pages and a large ecosystem of browser, server and desktop software.
- UTF-8 – A variable-width character encoding that represents every Unicode code point using one to four bytes.
- ASCII – A 7-bit character encoding that assigns numbers to 128 letters, digits, symbols and control codes.
- HTML – The standard markup language used to structure documents and applications on the World Wide Web.
- Tim Berners-Lee – British computer scientist who invented the World Wide Web.
- CSS – The style sheet language that controls the presentation, layout and responsive behaviour of HTML documents.
- HTTP/3 – The third major version of the Hypertext Transfer Protocol, which runs over QUIC instead of TCP.
- POSIX – A family of IEEE standards that specify a portable interface for Unix-like operating systems.
