{ } JSON Workbench100% Private • Zero Server Uploads

JSON examples

Copy-ready examples of every common JSON shape, from a simple object to API responses, config files, dates, and JSON Schema. Every example on this page is valid JSON (checked automatically), and the last section shows the mistakes that make JSON invalid. New to the format? Start with What is JSON? To try any example, paste it into the JSON Formatter or the JSON Viewer.

Simple JSON object example

The most common shape: an object of key/value pairs. Keys are always double-quoted strings.

{
  "id": 42,
  "name": "Ada Lovelace",
  "email": "[email protected]",
  "active": true
}

Example with every JSON data type

JSON has exactly six value types: string, number, boolean, null, array, and object.

{
  "string": "hello",
  "integer": 42,
  "decimal": 3.14,
  "negative": -7,
  "exponent": 1.5e3,
  "boolean": false,
  "nothing": null,
  "array": [1, "two", true],
  "object": { "nested": "value" }
}

Numbers have no quotes and no leading zeros (07 is invalid). There is no separate integer type, no NaN, and no Infinity.

JSON array example (array of objects)

A list of records, the shape most APIs return and most tools (tables, CSV, Excel) expect. View it as a table or export it with JSON to CSV.

[
  { "id": 1, "name": "Ada", "role": "admin" },
  { "id": 2, "name": "Linus", "role": "editor" },
  { "id": 3, "name": "Grace", "role": "viewer" }
]

A JSON document can be an array at the top level; it does not have to be an object.

Nested JSON object example

Objects and arrays can nest to any depth. To get the access path of any nested value, use the JSON path finder.

{
  "id": 7,
  "name": "Workbench Books",
  "address": {
    "street": "1 Main St",
    "city": "Paris",
    "geo": { "lat": 48.8566, "lng": 2.3522 }
  },
  "tags": ["books", "tech"],
  "owners": [
    { "name": "Ada", "share": 0.6 },
    { "name": "Linus", "share": 0.4 }
  ]
}

JSON API response example

A typical paginated REST response: the records under data, paging details under meta, and navigation under links.

{
  "data": [
    { "id": "ord_1001", "status": "shipped", "total": 59.9, "currency": "EUR" },
    { "id": "ord_1002", "status": "pending", "total": 12.5, "currency": "EUR" }
  ],
  "meta": { "page": 1, "pageSize": 2, "totalItems": 37 },
  "links": {
    "self": "https://api.example.com/orders?page=1",
    "next": "https://api.example.com/orders?page=2"
  }
}

JSON error response example

A consistent error body makes failures easy to handle. This one follows the shape of RFC 9457 (Problem Details).

{
  "type": "https://example.com/errors/validation",
  "title": "Invalid request",
  "status": 422,
  "detail": "email must be a valid address",
  "errors": [{ "field": "email", "message": "is not a valid email" }]
}

JSON config file example

Configuration files are one of the most common places to meet JSON, like this package.json for a Node.js project.

{
  "name": "my-app",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "test": "vitest run"
  },
  "dependencies": {
    "react": "18.3.1"
  }
}

JSON date format example

JSON has no date type, so dates are strings. Use ISO 8601: it sorts correctly, includes the time zone, and every language can parse it.

{
  "date": "2026-11-13",
  "createdAt": "2026-11-13T09:30:00Z",
  "updatedAt": "2026-11-13T11:30:00+02:00",
  "expiresAtUnix": 1794563400
}

Z means UTC. A Unix timestamp (seconds since 1970) is the other common choice, stored as a number.

JSON null example

null means "no value". It is lowercase and unquoted.

{
  "middleName": null,
  "manager": null,
  "tags": []
}

null is different from a missing key, an empty string "", and an empty array []. Many APIs use null for "known to be empty" and omit the key for "not provided".

JSON escape characters example

Inside strings, quotes, backslashes, and control characters must be escaped with a backslash.

{
  "quote": "She said \"hello\"",
  "path": "C:\\Users\\ada",
  "multiline": "line 1\nline 2",
  "tab": "col1\tcol2",
  "unicode": "caf\u00e9 \u2713"
}

Escape \" \\ \n \t \r \b \f \/ and \uXXXX. Use JSON Escape to escape text automatically, or string to JSON to reverse it.

JSON Schema example

A JSON Schema describes and validates the shape of other JSON. This one validates the simple object example above.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": { "type": "integer" },
    "name": { "type": "string", "minLength": 1 },
    "email": { "type": "string", "format": "email" },
    "active": { "type": "boolean" }
  },
  "required": ["id", "name", "email"],
  "additionalProperties": false
}

Check a document against it with the JSON Schema validator, or infer a schema from your own data with the JSON Schema generator.

GeoJSON example

GeoJSON (RFC 7946) is JSON for map data. Note the coordinate order: longitude first, then latitude.

{
  "type": "Feature",
  "geometry": { "type": "Point", "coordinates": [2.3522, 48.8566] },
  "properties": { "name": "Paris" }
}

Invalid JSON examples (common mistakes)

These look like JSON but fail to parse. Each comes with the fix. The JSON Repair tool fixes all of them automatically, and the JSON Validator points to the exact line.

MistakeInvalidValidWhy
Single quotes{ 'name': 'Ada' }{ "name": "Ada" }JSON only allows double quotes, for keys and string values.
Trailing comma{ "a": 1, "b": 2, }{ "a": 1, "b": 2 }No comma after the last item in an object or array.
Unquoted key{ name: "Ada" }{ "name": "Ada" }Keys must be double-quoted strings.
Comments{ "a": 1 // note }{ "a": 1 }JSON has no comment syntax (see can JSON have comments?).
Python / JS literals{ "ok": True, "x": None, "y": undefined }{ "ok": true, "x": null }Use lowercase true, false, and null; undefined does not exist in JSON.

How to create a JSON file

  1. Open a plain-text editor (VS Code is ideal; Notepad on Windows or TextEdit in plain-text mode on Mac also work).
  2. Write or paste your JSON, for example the simple object above.
  3. Check it parses: paste it into the JSON Validator.
  4. Save it with a .json extension (like data.json) in UTF-8 encoding.

From code:

// JavaScript (Node.js)
import { writeFileSync } from "node:fs";
writeFileSync("data.json", JSON.stringify(data, null, 2));

# Python
import json
with open("data.json", "w", encoding="utf-8") as f:
    json.dump(data, f, indent=2, ensure_ascii=False)

To open one later, see how to open a JSON file.

Related tools and guides

Frequently asked questions

What is a simple JSON example?

{"id": 42, "name": "Ada", "active": true} is a complete JSON document: an object with a number, a string, and a boolean. Keys are double-quoted strings, values follow a colon, and pairs are separated by commas.

How do I create a JSON file?

Write valid JSON in any text editor (VS Code, Notepad, TextEdit in plain-text mode) and save it with a .json extension using UTF-8 encoding. Paste it into a JSON validator first to make sure it parses. In code, write it with JSON.stringify(data, null, 2) (JavaScript) or json.dump(data, f, indent=2) (Python).

What is the correct JSON format?

A JSON document is one value: an object {}, an array [], a string, a number, true, false, or null. Strings and keys use double quotes, there are no comments and no trailing commas, and the file should be UTF-8.

Where can I get sample JSON data for testing?

Copy any example on this page, or generate as many realistic records as you need from one sample with the JSON Generator (names, emails, dates, ids).

Can a JSON file start with an array?

Yes. Since RFC 7159 (2014), any JSON value can be the top level, so [{...}, {...}] is a valid JSON document. Many APIs still wrap arrays in an object (like {"data": [...]}) to leave room for metadata.