JSONBeautifier.io
Guide · 5 min read

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data format used to store and exchange structured data. It is the universal language of APIs — almost every web service sends and receives data as JSON. This guide explains what JSON is, how it works, and why it matters.

JavaScript Object
Valid JSON
// JavaScript object (NOT JSON)
const user = {
  name: 'Alice',
  age: 30,
  active: true
}

JSON in Plain English

JSON is a way to represent data as text so it can be sent between systems — between a server and a browser, between two microservices, or stored in a file. It was derived from JavaScript object syntax but is completely language-independent: Python, Go, Java, Ruby, and virtually every other language has built-in JSON support.

JSON was defined in RFC 8259 and is the most widely used data interchange format in software today, having largely replaced XML for web APIs.

JSON Syntax Rules

Data is in key/value pairs
"name": "Alice"
Keys must be strings in double quotes
"key": value
Values can be string, number, boolean, null, object, or array
"active": true
Objects are wrapped in curly braces { }
{"name": "Alice"}
Arrays are wrapped in square brackets [ ]
["red", "green", "blue"]
Items are separated by commas — no trailing comma allowed
{"a": 1, "b": 2}
No comments are allowed
// this would break JSON

JSON Data Types

JSON supports exactly 6 data types:

TypeExampleNote
String"name": "Alice"Must use double quotes
Number"age": 30Integer or float, no quotes
Boolean"active": truetrue or false, lowercase
Null"nickname": nullRepresents no value
Object"address": { "city": "NYC" }Nested key-value pairs
Array"tags": ["web", "api"]Ordered list of values

JSON vs XML — Why JSON Won

Before JSON, XML was the dominant data exchange format for web APIs (SOAP, RSS, etc.). JSON replaced it for most use cases because:

Simpler syntax
JSON: No opening/closing tags
XML: Every value needs a tag pair
Smaller file size
JSON: 20–30% smaller than equivalent XML
XML: Verbose tag structure adds overhead
Native to JavaScript
JSON: JSON.parse() and JSON.stringify() built-in
XML: Requires DOM parsing library
Easier to read
JSON: Key-value structure is intuitive
XML: Deeply nested tags are hard to scan

XML is still used in specific domains — SOAP APIs, RSS/Atom feeds, SVG, and some enterprise systems. But for modern REST APIs, JSON is the standard.

A Real-World JSON Example

Here is what a typical REST API response looks like — a user object with nested address and an array of roles:

{
  "id": 1042,
  "name": "Alice Johnson",
  "email": "[email protected]",
  "age": 30,
  "active": true,
  "address": {
    "street": "123 Main St",
    "city": "New York",
    "country": "US"
  },
  "roles": ["admin", "editor"],
  "lastLogin": null
}

Try the Free JSON Beautifier

Paste any JSON and instantly get a readable, validated, formatted version.

Open JSON Beautifier

Related Guides