Guide

What is JSON?

JSON is the most widely used format for exchanging data on the web. Here’s everything you need to know — from syntax to real-world use.

JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and exchanging structured data. It was popularised by Douglas Crockford in the early 2000s, standardised as RFC 8259 and ECMA-404, and is now the default format for web APIs, configuration files, NoSQL databases and logs.

Although it grew out of JavaScript, JSON is language-independent: every mainstream language can read and write it.

A first example

{
  "name": "Ada Lovelace",
  "born": 1815,
  "mathematician": true,
  "languages": ["English", "French"],
  "spouse": { "name": "William King", "title": "Earl of Lovelace" },
  "website": null
}

This object has six members. Each member is a key (always a double-quoted string) followed by a colon and a value.

The six JSON data types

TypeExampleNotes
String"hello"Double quotes only; escape \", \\, \n, \uXXXX
Number42, -3.14, 1e10No leading zeros, no NaN or Infinity, no hex
Booleantrue, falseLowercase only
NullnullLowercase only
Object{"a": 1}Unordered key/value pairs
Array[1, "two", true]Ordered list of any values

Dates, binary data and comments are not part of JSON. Dates are usually written as ISO 8601 strings ("2026-03-14T09:26:53Z") and binary data as Base64 strings.

JSON syntax rules

Breaking any of these rules makes the JSON invalid. Paste it into the JSON Validator to see exactly where and why.

JSON vs XML vs YAML

JSONXMLYAML
ReadabilityGoodVerboseExcellent
CommentsNoYesYes
Typical useAPIs, data exchangeDocuments, SOAP, enterpriseConfig files, CI/CD, Kubernetes
Parsing speedVery fastSlowerSlower

You can convert between them with the JSON to XML, XML to JSON and JSON to YAML converters.

Reading and writing JSON in code

// JavaScript
const data = JSON.parse('{"id": 1, "tags": ["a", "b"]}');
const text = JSON.stringify(data, null, 2);

# Python
import json
data = json.loads('{"id": 1}')
text = json.dumps(data, indent=2)

// Go
var order Order
err := json.Unmarshal(bytes, &order)

For typed languages, generate the classes automatically from a sample: TypeScript, Python, Go, Java, C# and 15 more languages.

Common pitfalls

Try it

Paste any JSON into the JSON Formatter to pretty-print, validate and explore it as a tree — everything runs privately in your browser.

Private by design

Your data never leaves your browser.

498 free tools that run locally — no uploads, no sign-up, no tracking of what you paste. They even work offline.

  • 498free tools
  • 0bytes uploaded
  • 23categories