The Six JSON Data Types
| Type | Example | Notes |
|---|---|---|
| string | "Hello" | Always double quotes |
| number | 42, -3.14, 1.5e3 | No leading zeros, no NaN |
| boolean | true, false | Lowercase only |
| null | null | Lowercase only |
| object | {"name": "Emily"} | Keys are strings |
| array | [1, 2, 3] | Values can be mixed types |
A Valid JSON Example
{
"id": 1024,
"name": "Emily Clark",
"email": "emily.clark@example.com",
"balance": 2500.75,
"active": true,
"manager": null,
"skills": ["JSON", "React"],
"address": { "city": "London", "country": "United Kingdom" }
}Rules for Objects and Arrays
- Objects use curly braces
{ }; arrays use square brackets[ ]. - Each key and value is separated by a colon:
"key": value. - Items are separated by commas, and there is no comma after the last item.
- Keys must be strings in double quotes. Keys should be unique in an object.
- The top level can be any value, but is usually an object or an array.
Rules for Strings
- Use double quotes:
"text", never'text'. - Real line breaks and tabs are not allowed inside a string; write
\nand\t. - Escape double quotes and backslashes:
\"and\\. - Any character can be written as
\ufollowed by four hex digits.
Rules for Numbers
- Allowed:
0,-12,3.14,6.02e23. - Not allowed: leading zeros (
007), a plus sign (+1), hex (0xFF),.5,5.,NaNorInfinity. - Very large integers may lose precision in JavaScript; send them as strings if exact values matter.
Things JSON Does Not Allow
{
name: "Emily", // key without quotes + a comment
'city': 'London', // single quotes
"active": True, // must be lowercase true
"score": 007, // leading zeros
"tags": ["a", "b",], // trailing comma
}Paste that example into our JSON Repair tool and it will fix every one of these problems automatically. To find the exact line of an error in your own data, use the JSON Validator.
Whitespace and Encoding
Spaces, tabs and line breaks between values are ignored, so the same JSON can be minified or pretty printed. JSON text should be encoded as UTF-8, and the official media type is application/json.
Check Your JSON Against These Rules
Paste your JSON into the JSON Validator to find the exact line and column of any rule that is broken. If a parser shows a message like "Unexpected token", the guide to Unexpected Token in JSON explains which rule it points to, and JSON Repair fixes the most common ones automatically.
Frequently Asked Questions
What are the data types in JSON?
JSON has six types: string, number, boolean (true/false), null, object and array.
Do JSON keys need double quotes?
Yes. Every key must be a string in double quotes, for example "name". Single quotes and unquoted keys are not allowed.
Is a trailing comma allowed in JSON?
No. A comma after the last item in an object or array makes the JSON invalid.
Can JSON numbers have leading zeros?
No. Numbers like 007 are invalid. NaN, Infinity and hex numbers like 0x1F are not allowed either.