figro
FigroGuides › What is JSON
Developer

What Is JSON? A Simple Guide with Examples

By the Figro team · Updated July 2026 · about a 6-minute read

JSON — short for JavaScript Object Notation — is a lightweight, text-based format for storing and exchanging structured data. It is the most widely used data interchange format on the web today: when your browser fetches a weather update, submits a login form, or loads a social feed, the server almost certainly responds with JSON. Despite its name, JSON is language-independent and is supported natively or through libraries in virtually every programming language.

The shortest possible definition

JSON is a way to represent structured data as plain text, using key-value pairs for objects and comma-separated values inside square brackets for arrays. A valid JSON document is either an object ({}), an array ([]), or a single primitive value. Every JSON file can be opened and read in a plain-text editor, which makes it easy to inspect, debug, and share.

Here is a minimal JSON object representing a user:

{
  "name": "Alice",
  "age": 30,
  "verified": true,
  "email": "alice@example.com"
}

Each entry is a key (always a double-quoted string) followed by a colon, then a value. Multiple entries are separated by commas. The whole thing is wrapped in curly braces.

The six value types JSON supports

JSON is deliberately minimal. It defines exactly six types of values:

TypeExampleNotes
String"hello"Must use double quotes — single quotes are not valid JSON
Number42, 3.14, -7Integers and decimals; no octal or hex literals
Booleantrue, falseLowercase only
NullnullRepresents an intentionally absent value
Object{"key": "value"}Unordered collection of key-value pairs
Array[1, "two", true]Ordered list; values may be mixed types

Objects and arrays can nest inside each other to any depth, which is what makes JSON expressive enough to describe complex real-world data.

A realistic example: nested JSON

Real API responses contain nested objects and arrays. Here is a JSON payload representing an order in an e-commerce system:

{
  "orderId": "ORD-8821",
  "status": "shipped",
  "customer": {
    "id": 4091,
    "name": "Bob Chen",
    "email": "bob@example.com"
  },
  "items": [
    {"sku": "HEADPH-01", "qty": 1, "unitPrice": 79.99},
    {"sku": "CABLE-USB-C", "qty": 2, "unitPrice": 8.50}
  ],
  "shippedAt": "2026-07-03T14:22:00Z"
}

The top-level object has string values ("orderId", "status"), a nested object ("customer"), an array of objects ("items"), and a datetime string. JSON has no dedicated date type — dates are conventionally stored as ISO 8601 strings and parsed by the application.

The rules: what makes JSON valid

JSON has a strict grammar. The rules that trip people up most often:

Tip: Most JSON parse errors are one of three things — a trailing comma, a single-quoted string, or an unquoted key. A JSON validator catches all three instantly.

How JSON is used in practice

JSON shows up in a wide range of situations in software development:

JSON vs XML: why JSON won

Before JSON became dominant, XML was the standard for web data exchange. Both formats represent structured data as text, but they differ in verbosity and ergonomics:

FeatureJSONXML
SyntaxKey-value pairs, arraysOpening and closing tags
VerbosityCompactMore verbose (repeated tag names)
CommentsNot supportedSupported (<!-- -->)
Native JS parsingJSON.parse() built inRequires DOMParser or a library
Schema validationJSON Schema (external)XSD, DTD (built into ecosystem)
Best forWeb APIs, config, app dataDocuments, SOAP, enterprise systems

JSON is smaller for equivalent data, maps directly onto the objects and arrays native to most programming languages, and is trivial to parse in JavaScript without any library. Those three advantages made it the default choice for web APIs as REST displaced SOAP, and it has stayed there.

Reading and writing JSON in code

Every major language has built-in or standard-library support for JSON. The pattern is always the same: parse a JSON string into a native data structure, and serialize a native data structure back to a JSON string.

In JavaScript:

// Parse a JSON string into a JS object
const user = JSON.parse('{"name":"Alice","age":30}');
console.log(user.name); // "Alice"

// Serialize a JS object to a JSON string
const json = JSON.stringify({ name: "Bob", active: true }, null, 2);
// The third argument (2) sets the indentation for pretty-printing

In Python:

import json

# Parse JSON string to dict
user = json.loads('{"name": "Alice", "age": 30}')
print(user["name"])  # Alice

# Serialize dict to JSON string
output = json.dumps({"name": "Bob", "active": True}, indent=2)

The pattern is identical in Go (encoding/json), Rust (serde_json), Java (Jackson or Gson), and PHP (json_encode / json_decode). The names differ; the concept does not.

Common mistakes and how to fix them

When a JSON document fails to parse, the error message usually points to a line and column. The most frequent culprits:

If you are staring at a blob of minified JSON (everything on one line, no spaces), it is nearly impossible to spot these issues by eye. Paste it into a formatter and the structure immediately becomes visible — and the validator will highlight exactly where the error is.

Format, validate, or minify JSON instantly

JSONForge is Figro's free, private JSON tool — format messy JSON into something readable, validate a document for syntax errors, minify for production, or explore your data with an interactive tree view. No signup, nothing uploaded to any server.

Open the free JSON formatter →

Figro's guides are educational and independent. They are not professional or legal advice. Some pages include affiliate links; if you purchase through them we may earn a commission at no extra cost to you.