What Is JSON?
How JSON Represents Data
What is JSON? It is JavaScript Object Notation, a lightweight text format for storing and exchanging structured data between programs. Despite its name, JSON is language-independent: nearly every modern programming language can read and write it.
JSON was derived from the object literal syntax of JavaScript and standardized in RFC 8259. Its appeal is simplicity. A JSON document is plain text that people can read, and its rules are small enough to learn in a few minutes.
JSON Syntax and Data Types
Every JSON value is one of six kinds: a string, a number, a boolean (true or false), null, an object or an array. An object is a set of key and value pairs wrapped in curly braces. An array is an ordered list of values wrapped in square brackets.
Keys and strings must be written in double quotes. A small example is {"name": "Ada", "active": true, "plan_ids": [3, 7]}. The format has no comments and no trailing commas, and it has no date type, so dates are normally sent as strings in a standard format such as ISO 8601.
Why JSON Became the Standard for APIs and Settings
Most web APIs send and receive JSON because browsers and most server languages can parse it with little code. A hosting control panel, a payment service and a mobile app can exchange the same structure without agreeing on a custom format. Many REST APIs return JSON by default for this reason.
JSON is also common in configuration files, because people and programs can both read and edit it easily. It has limits. The core format has no built-in way to describe the shape of the data, so teams document structure separately, often with JSON Schema or an API specification. For a comparison with the older XML format, see JSON vs XML.
Frequently asked questions
Is JSON the same as a JavaScript object?
No. JSON is a text format, so it is a string of characters that a program must parse before using it. A JavaScript object is a structure that exists in memory once the code creates it. JSON looks similar because its syntax comes from object literals, but it follows stricter rules, such as requiring double quotes around keys.
Is JSON secure?
JSON is a data format, not a security mechanism. It does not encrypt or sign its contents, so anyone who can read the data can read the JSON. Security depends on encrypted connections such as HTTPS, access control and validating input before the data is used.