JSON Formatter Hub
This page is a compact reference for JSON syntax. Use the JSON Formatter to try any of these examples directly โ paste them in and explore the tree view to understand the structure.
JSON has exactly six value types:
{
"stringValue": "Hello, world!",
"integerValue": 42,
"floatValue": 3.14159,
"booleanTrue": true,
"booleanFalse": false,
"nullValue": null
}
| Type | Example | Notes |
|---|---|---|
| String | "Hello" |
Must use double quotes. Single quotes are invalid. |
| Number | 42, -7, 3.14, 1e5 |
No leading zeros. No quotes. Scientific notation allowed. |
| Boolean | true, false |
Lowercase only. True or TRUE are invalid. |
| Null | null |
Lowercase only. Represents no value. |
| Object | {"key": "value"} |
Unordered key-value pairs. Keys must be strings. |
| Array | [1, 2, 3] |
Ordered list. Elements can be any type. |
{
"key": "value",
"anotherKey": 123,
"lastKey": true
}
:["apple", "banana", "cherry"]
[1, 2.5, true, null, "mixed", {"nested": "object"}]
[ ]{
"user": {
"id": 1,
"name": "Alice",
"address": {
"street": "123 Main St",
"city": "London",
"country": "UK"
}
}
}
{
"users": [
{"id": 1, "name": "Alice"},
{"id": 2, "name": "Bob"},
{"id": 3, "name": "Charlie"}
]
}
{
"matrix": [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
}
{
"order": {
"id": "ORD-001",
"customer": {
"name": "Alice",
"email": "alice@example.com"
},
"items": [
{
"productId": "P101",
"name": "Widget",
"quantity": 2,
"price": 9.99,
"tags": ["electronics", "small"]
}
],
"total": 19.98,
"paid": true,
"notes": null
}
}
Special characters inside JSON strings must be escaped with a backslash:
| Escape | Meaning | Example |
|---|---|---|
\" |
Double quote | "He said \"hello\"" |
\\ |
Backslash | "C:\\Users\\Alice" |
\/ |
Forward slash (optional) | "https:\/\/example.com" |
\n |
Newline | "Line 1\nLine 2" |
\r |
Carriage return | "Line 1\r\nLine 2" |
\t |
Tab | "col1\tcol2" |
\uXXXX |
Unicode code point | "รฉ" โ รฉ |
{
"status": "success",
"data": {
"id": 42,
"name": "Widget"
},
"message": null,
"timestamp": "2025-05-10T09:00:00Z"
}
{
"page": 1,
"perPage": 20,
"total": 143,
"data": [
{"id": 1, "name": "Item 1"},
{"id": 2, "name": "Item 2"}
]
}
{
"status": "error",
"code": 404,
"message": "Resource not found",
"details": {
"field": "userId",
"reason": "No user with id 9999"
}
}
{
"appName": "my-service",
"version": "2.1.0",
"server": {
"host": "0.0.0.0",
"port": 8080,
"debug": false
},
"database": {
"host": "db.example.com",
"port": 5432,
"name": "production_db",
"ssl": true
},
"features": {
"darkMode": true,
"betaFeatures": false
},
"allowedOrigins": [
"https://app.example.com",
"https://www.example.com"
]
}
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-0.1276, 51.5074]
},
"properties": {
"name": "London"
}
}
| Not Allowed | Workaround |
|---|---|
Comments (// or /* */) |
Use a separate docs file or JSON5 if your toolchain supports it |
Single-quoted strings ('value') |
Always use double quotes: "value" |
Trailing commas ([1, 2,]) |
Remove the last comma |
Unquoted keys ({key: 1}) |
Quote all keys: {"key": 1} |
Leading zeros in numbers (007) |
Use 7 (or "007" as a string if zero-padding matters) |
| Native date type | Encode as ISO 8601 string: "2025-05-10T09:00:00Z" |
undefined |
Use null to represent the absence of a value |
| Functions or code | JSON is data only โ no executable content |
| Binary data (images, files) | Encode as Base64 string |
| Infinity / NaN | Use null or a sentinel string like "Infinity" |
Before submitting a JSON payload to an API or saving a config file, verify:
true / falsenullundefined, no functionsRun your JSON through the JSON Formatter & Validator to check all of the above automatically. Use the Auto-fix button to repair the most common issues.