Guide
JSON Examples
Copy-ready JSON samples that show every data type and the structures you’ll meet in real APIs and config files.
Each example below is valid JSON. Paste any of them into the JSON Formatter to explore the structure as a tree, or into the JSON to TypeScript tool to generate types.
1. Every data type in one object
{
"string": "Hello, JSON",
"integer": 42,
"decimal": 3.14159,
"scientific": 6.022e23,
"negative": -17,
"boolean": true,
"nothing": null,
"array": [1, "two", false, null],
"object": { "nested": "value" },
"escaped": "Line one\nLine \"two\" \u00e9"
}
2. An array of objects (a typical API list)
[
{ "id": 1, "name": "Ada Lovelace", "email": "ada@example.com", "active": true },
{ "id": 2, "name": "Alan Turing", "email": "alan@example.com", "active": false },
{ "id": 3, "name": "Grace Hopper", "email": "grace@example.com", "active": true }
]
Arrays of flat objects convert naturally to tables — try it with JSON to CSV.
3. Nested data: an e-commerce order
{
"orderId": "ord_8f2k1x",
"createdAt": "2026-03-14T09:26:53Z",
"customer": { "id": 48213, "name": "Ada Lovelace", "vip": true },
"items": [
{ "sku": "KB-104", "name": "Mechanical Keyboard", "qty": 1, "price": 89.99 },
{ "sku": "MS-220", "name": "Wireless Mouse", "qty": 2, "price": 19.98 }
],
"shipping": {
"carrier": "UPS",
"address": { "line1": "12 Analytical Engine Way", "city": "London", "postcode": "EC1A 1BB" }
},
"discountCode": null
}
Query nested values with the JSONPath Tester, e.g. $.items[*].sku.
4. A REST API response with pagination
{
"data": [
{ "id": "u_101", "type": "user", "attributes": { "name": "Ada" } }
],
"meta": { "page": 1, "perPage": 20, "total": 1 },
"links": { "self": "/users?page=1", "next": null }
}
5. An error response
{
"error": {
"code": "VALIDATION_FAILED",
"message": "Email is not valid",
"details": [{ "field": "email", "rule": "format" }]
}
}
6. A configuration file (package.json style)
{
"name": "my-app",
"version": "1.4.2",
"private": true,
"scripts": { "dev": "vite", "build": "vite build", "test": "vitest" },
"dependencies": { "react": "^19.0.0" },
"engines": { "node": ">=20" }
}
7. GeoJSON
{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [-0.1276, 51.5072] },
"properties": { "name": "London", "population": 8982000 }
}
Note that GeoJSON coordinates are [longitude, latitude].
8. JSON Lines (NDJSON)
{"ts":"2026-03-14T09:00:00Z","level":"info","msg":"server started"}
{"ts":"2026-03-14T09:00:02Z","level":"warn","msg":"slow query","ms":812}
JSON Lines puts one JSON value per line — great for logs and streaming. The whole file is not a single JSON document, so wrap the lines in [ … ] with commas to parse it as an array.
9. Invalid JSON (and how to fix it)
{
name: 'Ada', // unquoted key, single quotes, comment
"tags": ["a", "b",] // trailing comma
}
Paste this into the JSON Validator to see each error explained — then click Auto-repair to fix them all at once.
Next steps
- What is JSON? — syntax and data types in depth
- Generate a JSON Schema from any of these examples
- Compare two JSON documents