Skip to main content

JSON

JavaScript Object Notation

Pronunciation
JAY-sun
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/json

In short

JSON is a lightweight, text-based format for storing and exchanging structured data as key-value pairs and lists, readable by both humans and machines.

What is JSON?

JSON is a simple way to write structured data as plain text. It uses curly braces for objects made of key-value pairs, square brackets for ordered lists called arrays, and a small set of value types: strings, numbers, booleans (true or false), null, objects, and arrays.

Although its syntax comes from JavaScript, JSON is language-independent, and almost every programming language can read and write it. Converting data into JSON text is called serialization, and turning JSON text back into data structures is called parsing; in JavaScript these are done with JSON.stringify() and JSON.parse().

JSON is the default data format for most web APIs, and it is also used for configuration files such as package.json, for logs, and for storing documents in NoSQL databases. Its popularity comes from being compact, easy for people to read, and easy for machines to process.

JSON is often confused with JavaScript objects, but it is stricter: keys must be in double quotes, strings cannot use single quotes, and comments, trailing commas, functions, and undefined are not allowed. Compared with XML, JSON is shorter and maps more directly to objects and arrays in code.

At a glance

A JSON object with one value of each type: a string, a number, a boolean, null, an array in square brackets and a nested object in curly braces, each under a key in double quotes.{"name": "Ada","age": 36,"admin": true,"manager": null,"skills": ["math", "code"],"address": { "city": "London" }}stringnumberbooleannullarray: an ordered listobject: keys and valuesobject { }
Keys and strings always take double quotes, and standard JSON allows no comments and no trailing commas.

Key takeaways

  • JSON stands for JavaScript Object Notation but works with almost every language.
  • Data is written as objects ({}), arrays ([]), strings, numbers, booleans, and null.
  • Keys and strings must use double quotes.
  • Standard JSON does not allow comments or trailing commas.
  • It is the most common data format for web APIs.

Example

A user record written in JSONjson
{
  "id": 42,
  "name": "Ada Lovelace",
  "email": "ada@example.com",
  "isAdmin": false,
  "roles": ["editor", "author"],
  "address": {
    "city": "London",
    "country": "UK"
  },
  "lastLogin": null
}

Readers ask

What is the difference between JSON and a JavaScript object?

A JavaScript object is a value in a running program, while JSON is a text format for representing data. JSON is also stricter: keys need double quotes, and functions, comments, and undefined are not allowed.

Can JSON have comments?

No. Standard JSON does not support comments, although some tools accept variants such as JSONC or JSON5 for configuration files.

What is the difference between JSON and XML?

Both are text formats for structured data. JSON is shorter and maps directly to objects and arrays in code, while XML uses opening and closing tags and is more common in older enterprise systems and document formats.

Often compared

See also

Sources

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings