Beautify, minify and validate JSON with precise error locations. Your data never leaves your browser.
JSON (JavaScript Object Notation) is the most common format for exchanging data on the web. APIs return it, config files use it, and databases store it. It’s simple enough to learn in ten minutes.
A first example
{
"name": "Ada Lovelace",
"born": 1815,
"mathematician": true,
"languages": ["English", "French"],
"address": {
"city": "London",
"country": "UK"
},
"spouse": null
}
That covers almost everything JSON can do.
The six data types
| Type | Example | Notes |
|---|---|---|
| String | "London" |
Double quotes only |
| Number | 1815, 3.14, -2, 6.02e23 |
No leading zeros, no NaN |
| Boolean | true, false |
Lowercase |
| Null | null |
Lowercase, means “no value” |
| Array | ["a", "b"] |
Ordered list, any types |
| Object | {"key": "value"} |
Unordered key–value pairs |
There are no date, binary or undefined types. Dates are usually stored as ISO 8601 strings such as "2026-11-07T14:30:00Z".
Objects
An object is a set of key–value pairs inside curly braces:
- Keys must be double-quoted strings.
- A colon separates each key and value.
- Commas separate pairs, with no trailing comma.
- Keys should be unique within an object.
Arrays
An array is an ordered list inside square brackets. Items can be any type, including other arrays and objects:
[
{ "id": 1, "tags": ["new", "sale"] },
{ "id": 2, "tags": [] }
]
Nesting
Objects and arrays can nest to any depth, which is how JSON represents complex data such as orders containing line items containing products. Deep nesting is hard to read in minified form; the JSON formatter indents it so the structure is obvious.
Whitespace and formatting
Whitespace outside strings is ignored, so these are identical:
{"a":1,"b":[1,2]}
{
"a": 1,
"b": [1, 2]
}
Use formatted JSON for humans (config files, docs, debugging) and minified JSON for machines (network payloads).
Naming conventions
JSON doesn’t enforce a style, but be consistent:
- camelCase:
firstName, common in JavaScript APIs - snake_case:
first_name, common in Python and Ruby APIs - kebab-case:
first-name, rare in JSON because it’s awkward in code
Best practices
- Be consistent with types. Don’t make
"price"a number in one record and a string in another. - Use
nulldeliberately. Decide whether missing fields are omitted or set tonull. - Prefer arrays of objects over objects keyed by ID when order matters.
- Store dates as ISO 8601 strings, in UTC.
- Keep money as integers (cents) or strings to avoid floating-point rounding.
- Validate before you ship. A single syntax error breaks the whole document; see Common JSON Errors and How to Fix Them.
Where JSON came from
JSON was popularised by Douglas Crockford in the early 2000s as a lightweight alternative to XML, and is standardised as ECMA-404 and RFC 8259. How it compares with XML and YAML is covered in JSON vs XML vs YAML: Which Data Format Should You Use?.
Beautify, minify and validate JSON with precise error locations. Your data never leaves your browser.