Friday, September 18, 2026

What Is JSON?

// data formats

What Is JSON?

JSON is a lightweight text-based format for representing structured data. It is widely used by websites, APIs, applications and programming languages to exchange information in a form that is relatively easy for both humans and computers to understand.

// definition

JSON means JavaScript Object Notation

JSON stands for JavaScript Object Notation.

It is a text-based format used to represent structured information using objects, arrays, names and values.

Although JSON originated from JavaScript syntax, it is now used independently by many programming languages and software systems.

// example

What does JSON look like?

Suppose we want to store information about a customer.

{ "name": "Alice Smith", "email": "alice@example.com", "orders": 4, "active": true }

This is a JSON object.

Each piece of information consists of a name and a value.

// name-value pairs

JSON uses name-value pairs

Consider this line:

"name": "Alice Smith"

The name of the property is:

"name"

and its value is:

"Alice Smith"

A colon separates the property name from its value. Commas separate different properties.

// objects

JSON objects use curly braces

An object begins with { and ends with }.

{ "product": "Keyboard", "price": 49.99, "stock": 12 }

Objects are useful when several named properties belong to the same thing.

// arrays

JSON arrays use square brackets

An array represents an ordered collection of values.

[ "HTML", "CSS", "JavaScript", "PHP" ]

Arrays begin with [ and end with ].

// collections

Arrays can contain objects

This is extremely common when working with APIs and databases.

[ { "name": "Alice", "orders": 4 }, { "name": "Ben", "orders": 7 }, { "name": "Carla", "orders": 2 } ]

Here, the array contains three separate customer objects.

// data types

JSON supports several kinds of values

Type Example
String "Freelance Coder"
Number 42
Boolean true
Null null
Object { "name": "Alice" }
Array [1, 2, 3]
// strings

JSON strings use double quotation marks

{ "city": "London" }

JSON requires strings and property names to use double quotation marks.

Important: JSON does not allow property names or strings to be written using single quotation marks in standard JSON syntax.

// boolean values

JSON can represent true and false

{ "active": true, "verified": false }

Boolean values are written without quotation marks.

// null

JSON can represent no value

{ "middleName": null }

The value null represents the intentional absence of a value.

// nesting

JSON can represent complex structures

Objects can contain other objects and arrays.

{ "customer": { "name": "Alice", "location": { "city": "Birmingham", "country": "United Kingdom" }, "orders": [ { "id": 1001, "total": 49.99 }, { "id": 1002, "total": 25.50 } ] } }

This creates a hierarchical structure in which related information can be grouped together.

// APIs

JSON is widely used by APIs

One of JSON's most important uses is transferring data between software systems.

For example, an application might request information about a product from an API and receive:

{ "id": 1042, "name": "Wireless Keyboard", "price": 39.99, "available": true }

The application can then read the JSON and use the values in its own interface or processing.

// data exchange

JSON helps systems communicate

Website ↓ API request ↓ Server ↓ JSON response ↓ Website

JSON provides a common structure that both sides can understand.

// json vs csv

JSON and CSV solve different problems

CSV works particularly well for simple tabular data.

Name,Orders Alice,4 Ben,7

JSON can represent more complex nested structures.

{ "customers": [ { "name": "Alice", "orders": [ 1001, 1002 ] } ] }
CSV JSON
Rows and columns Objects and arrays
Excellent for tables Excellent for structured data
Flat structure Can be nested
// json vs xml

JSON and XML can represent similar data

This XML:

<customer> <name>Alice</name> <orders>4</orders> </customer>

could be represented in JSON as:

{ "customer": { "name": "Alice", "orders": 4 } }

JSON is often more compact for application data, while XML provides additional features that can be useful for document-oriented and specialised systems.

// plain text

JSON is a text format

JSON may represent complex information, but the underlying document is still text.

This means JSON can be opened in a text editor, transmitted over a network and processed by many different programming languages.

Text-Based Structured Portable Machine-Readable Human-Readable
// utf-8

JSON and UTF-8

JSON exchanged between systems is commonly encoded using UTF-8.

{ "name": "João", "currency": "£", "symbol": "π", "message": "Olá" }

UTF-8 allows JSON to represent a very wide range of Unicode characters reliably.

// .json files

JSON can be stored in .json files

JSON data saved as a standalone file normally uses the .json file extension.

customers.json products.json settings.json data.json

JSON does not have to exist as a separate file, however. It can also be sent directly between applications and APIs.

// advantages

Why is JSON so widely used?

Readable

Its structure is relatively easy for people to inspect and understand.

Lightweight

JSON can represent structured information without large amounts of additional markup.

Structured

Objects, arrays and nested values can represent sophisticated data structures.

Widely supported

Most modern programming languages and web technologies can read and generate JSON.

// uses

Where is JSON used?

APIs Web Applications Databases Configuration Automation AI Systems Data Exchange JavaScript Mobile Apps Cloud Services
// syntax

JSON syntax is strict

Valid JSON must follow specific rules.

Property names use double quotes.

Strings use double quotes.

Properties are separated by commas.

Trailing commas are not permitted in standard JSON.

For example, this is valid:

{ "name": "Alice", "age": 30 }

But this is not valid standard JSON:

{ 'name': 'Alice', 'age': 30, }
// summary

Simple text. Structured information.

JSON is a text-based format for representing structured data using objects, arrays and name-value pairs. Its simplicity, flexibility and widespread software support make it one of the most important formats for APIs, websites, applications, automation and modern data exchange.

What Is PHP?

// server-side programming What Is PHP ? PHP is a programming language widely use...