JSON Examples

Updated: August 8, 2026

Copy-ready JSON samples — from a minimal object to a realistic API response, plus deliberately broken documents for testing your error handling.

The Minimum

A JSON document is exactly one value, so the smallest valid documents are surprisingly small. All five of these are complete and legal:

null
42
true
"a string"
{}

The bare-value cases catch people out, because the common assumption is that JSON must start with a brace. That was true under the older RFC 4627, which required an object or array at the root; RFC 8259 relaxed it. A handful of very old parsers still reject them.

A Simple Object

Every JSON type in one small document — useful for checking that a parser handles all of them:

{
  "id": 101,
  "name": "Alice Kumar",
  "email": "alice@example.com",
  "age": 30,
  "isActive": true,
  "balance": 1250.75,
  "roles": ["admin", "editor"],
  "address": {
    "street": "12 Anna Salai",
    "city": "Chennai",
    "postalCode": "600002",
    "country": "IN"
  },
  "lastLoginAt": "2026-08-07T09:15:00Z",
  "deletedAt": null
}

A Paginated API Response

The shape most real endpoints return: an envelope with a data array and pagination metadata. Note that every record carries the same keys, with null where a value is missing rather than omitting the field.

{
  "data": [
    {
      "id": 101,
      "name": "Alice Kumar",
      "email": "alice@example.com",
      "role": "admin",
      "createdAt": "2026-01-14T08:22:11Z"
    },
    {
      "id": 102,
      "name": "Bob Sharma",
      "email": null,
      "role": "editor",
      "createdAt": "2026-03-02T17:45:09Z"
    }
  ],
  "meta": {
    "page": 1,
    "perPage": 50,
    "total": 1284,
    "hasMore": true
  }
}

A Deeply Nested Document

Good for testing tree views, collapsing behaviour and recursive traversal code:

{
  "organisation": {
    "id": "org_9f2",
    "name": "Northwind Trading",
    "departments": [
      {
        "name": "Engineering",
        "teams": [
          {
            "name": "Platform",
            "members": [
              { "id": 1, "name": "Alice", "skills": ["go", "kubernetes"] },
              { "id": 2, "name": "Bob", "skills": ["rust"] }
            ]
          },
          {
            "name": "Frontend",
            "members": [
              { "id": 3, "name": "Carol", "skills": ["react", "typescript"] }
            ]
          }
        ]
      },
      {
        "name": "Design",
        "teams": []
      }
    ]
  }
}

A Configuration File

{
  "$schema": "https://example.com/schemas/app-config.json",
  "appName": "reporting-service",
  "environment": "production",
  "server": {
    "host": "0.0.0.0",
    "port": 8080,
    "timeoutMs": 30000
  },
  "database": {
    "poolSize": 20,
    "readReplicas": ["db-r1.internal", "db-r2.internal"]
  },
  "features": {
    "exportToCsv": true,
    "betaDashboard": false
  },
  "logLevel": "info"
}

The $schema key is worth including in config files. Editors such as VS Code read it and provide autocomplete and inline validation with no further setup — see the JSON Schema guide.

GeoJSON

A standardised JSON format for geographic data, defined by RFC 7946:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [80.2707, 13.0827]
      },
      "properties": {
        "name": "Chennai",
        "population": 7088000
      }
    }
  ]
}

Note the coordinate order: longitude first, then latitude. This is the reverse of the latitude-longitude convention used almost everywhere else, and mixing them up is the most common GeoJSON bug — your points end up in the wrong hemisphere.

JSON Lines

One complete JSON document per line, the standard format for logs and large data exports. The file as a whole is not valid JSON — each line is.

{"timestamp":"2026-08-07T09:15:00Z","level":"info","message":"server started"}
{"timestamp":"2026-08-07T09:15:04Z","level":"warn","message":"slow query","durationMs":1420}
{"timestamp":"2026-08-07T09:15:09Z","level":"error","message":"upstream timeout","service":"billing"}

The advantage is that you can process a file of any size at constant memory by reading one line at a time, and append new records without rewriting anything. Covered further on the Python page.

Deliberately Invalid Examples

Every one of these fails to parse. Use them to check that your error handling reports something more helpful than "invalid JSON" — each triggers a different message.

{ "name": "Alice", }                    // trailing comma

{ 'name': 'Alice' }                     // single quotes

{ name: "Alice" }                       // unquoted key

{ "quote": "She said "hi"" }            // unescaped inner quotes

{ "path": "C:\Users\Alice" }           // unescaped backslashes

{ "value": undefined }                  // undefined is not a JSON value

{ "count": 01 }                         // leading zero

{ "a": 1                                // unclosed brace

{
  // a comment
  "name": "Alice"
}                                        // JSON has no comments

Paste any of these into the parser to see the exact line and column reported. The errors guide explains what each message means and why the reported position is often one line below the real mistake.

Generating Large Test Files

For load testing or checking how a tool behaves on big documents, generating locally beats downloading a fixture — you control the size and shape exactly.

// Node.js — a 10,000-record file
import { writeFileSync } from "node:fs";

const records = Array.from({ length: 10_000 }, (_, i) => ({
  id: 1000 + i,
  name: `User ${i}`,
  email: `user${i}@example.com`,
  active: i % 3 !== 0,
  createdAt: new Date(Date.UTC(2026, 0, 1 + (i % 365))).toISOString(),
}));

writeFileSync("large.json", JSON.stringify({ data: records }, null, 2));
# Python equivalent
import json

records = [
    {"id": 1000 + i, "name": f"User {i}", "active": i % 3 != 0}
    for i in range(10_000)
]

with open("large.json", "w", encoding="utf-8") as f:
    json.dump({"data": records}, f, indent=2)

Frequently Asked Questions

Where can I get sample JSON data for testing?

The examples on this page are copy-ready and cover the shapes you are most likely to need — a flat object, a paginated list, a deeply nested document, and several deliberately broken files for testing error handling.

What is the smallest valid JSON document?

A single value. The literal null is four characters and is a complete, valid document, as are 0, true and "". If you need the smallest useful container, {} and [] are two characters each.

How do I generate large JSON files for load testing?

A short script is usually the most practical route — build a list of records in a loop and serialise it. Generating locally is preferable to downloading a fixture, because you control the size and shape precisely.

Is it safe to paste real data into an online JSON tool?

Only if the tool runs client-side. This one parses in your browser and never uploads anything, so production payloads are safe to inspect. Many online tools do POST your input to a server — if you cannot tell, check whether the tool still works with your network disconnected.

Related Resources

Related Resources