NV ToolkitFormat · Validate · Convert
Reference

JSON Examples: From Hello World to Real API Payloads

The fastest way to learn JSON is to read good JSON. Here are copy-ready examples for every common shape — from a minimal object to a realistic API payload — each annotated with what matters.

In short

This reference collects copy-ready JSON examples for every common shape: a minimal object, arrays of values and of objects, nested objects with null, a realistic API envelope with pagination metadata, and configuration-style nesting. Each example uses double-quoted keys and strings, typed numbers and booleans, and no trailing commas — the patterns that appear in real API payloads and config files.

By NaveenKumar T · Software engineer · builds and maintains NV Toolkit Published 2026-06-04 2 min read

A minimal object

The smallest useful JSON: one object, three keys, three different value types. Note the double quotes on keys and string values, and the absence of a trailing comma after the last pair.

json
{
  "id": 101,
  "name": "Mechanical Keyboard",
  "inStock": true
}

Arrays — of values and of objects

Arrays hold ordered values of any type. The array-of-objects pattern below is the single most common shape in real APIs: a list of records, each with the same fields. When you convert JSON to CSV, each of these objects becomes one row.

json
{
  "tags": ["sale", "wireless", "new"],
  "items": [
    { "sku": "KB-75", "qty": 1, "price": 149.99 },
    { "sku": "MS-12", "qty": 2, "price": 39.5 }
  ]
}

Nesting and null

Objects nest to any depth, and null states explicitly that a value is absent — different from omitting the key entirely. Consumers should handle both: shippedAt may be null today and a timestamp tomorrow.

json
{
  "order": {
    "id": "ORD-2026-0612",
    "customer": { "name": "Ada Lovelace", "vip": true },
    "shippedAt": null
  }
}

A realistic API response

Production APIs wrap data in an envelope: a status, the payload, and metadata like pagination. This is the shape you'll meet daily — and the one worth practicing with a tree viewer to navigate quickly.

json
{
  "status": "success",
  "data": [
    { "id": 1, "email": "ada@example.com", "roles": ["admin"] },
    { "id": 2, "email": "grace@example.com", "roles": ["editor", "billing"] }
  ],
  "meta": { "page": 1, "perPage": 20, "total": 137 }
}

Configuration file style

Config JSON favors nested objects over arrays, grouping settings by domain. (If you find yourself wanting comments in files like this, that's what JSON5 — and our JSON5 tools — exist for.)

json
{
  "server": { "port": 8080, "host": "0.0.0.0" },
  "logging": { "level": "info", "format": "json" },
  "features": { "darkMode": true, "beta": false }
}
How this was tested: Syntax examples were validated with the site's own parser (JSON.parse) on 2026-09-10.

Sources

  1. RFC 8259 — The JSON Data Interchange Format
  2. MDN — JSON
  3. MDN — Response.json()

Frequently asked questions

Can JSON contain dates?

Not natively — JSON has no date type. The universal convention is ISO 8601 strings ("2026-06-04T09:30:00Z"), which sort correctly as text and parse in every language. Unix timestamps as numbers are the compact alternative.

What's the most common JSON structure in real APIs?

An envelope object containing an array of records plus metadata: { "data": [...], "meta": { "page": 1 } }. Learn to read that shape fluently and most API responses become instantly familiar.

How can I test and modify these examples?

Paste any of them into our JSON Editor — you get live validation while you experiment, a tree view to see the structure, and one-click conversion to CSV, YAML, or XML to see the same data in other formats.

Paste any of these into the JSON Editor and modify them with live validation — the fastest way to build intuition.

Experiment live

Keep working

Related tools

JSON Formatter

Format, beautify, and validate JSON instantly in a professional VS Code-style editor — free, fast, and 100% private.

JSON Editor

A full VS Code-style editing experience for JSON — highlighting, error squiggles, undo/redo, search, and formatting in one place.

JSON Viewer

Explore any JSON document in an interactive, collapsible tree — keys, types, and counts at a glance, with code view one click away.

JSON to CSV

Flatten JSON arrays into spreadsheet-ready CSV — nested keys become dot-path columns, quoting handled for you.

JSONPath Tester

Paste a document, write an expression, and see exactly what it selects. Two dialects in one page — JSONPath for recursive descent and filters, JMESPath for projections and reshaping — evaluated entirely in your browser.

JSON to TypeScript

Paste a JSON or XML sample — the format is auto-detected — and get typed TypeScript models with names, nesting and nullability inferred for you.

JSON to Java

Paste a JSON or XML sample — the format is auto-detected — and get typed Java models with names, nesting and nullability inferred for you.

JSON to Python

Paste a JSON or XML sample — the format is auto-detected — and get typed Python models with names, nesting and nullability inferred for you.

JSON to C#

Paste a JSON or XML sample — the format is auto-detected — and get typed C# models with names, nesting and nullability inferred for you.

JSON to Go

Paste a JSON or XML sample — the format is auto-detected — and get typed Go models with names, nesting and nullability inferred for you.

JSON to JSON Schema

Paste a JSON or XML sample — the format is auto-detected — and get typed JSON Schema models with names, nesting and nullability inferred for you.

JSON to Kotlin

Paste a JSON or XML sample — the format is auto-detected — and get typed Kotlin models with names, nesting and nullability inferred for you.

JSON to Swift

Paste a JSON or XML sample — the format is auto-detected — and get typed Swift models with names, nesting and nullability inferred for you.

JSON to Rust

Paste a JSON or XML sample — the format is auto-detected — and get typed Rust models with names, nesting and nullability inferred for you.

JSON to Dart

Paste a JSON or XML sample — the format is auto-detected — and get typed Dart models with names, nesting and nullability inferred for you.

JSON to Ruby

Paste a JSON or XML sample — the format is auto-detected — and get typed Ruby models with names, nesting and nullability inferred for you.

JSON to C++

Paste a JSON or XML sample — the format is auto-detected — and get typed C++ models with names, nesting and nullability inferred for you.

JSON to Objective-C

Paste a JSON or XML sample — the format is auto-detected — and get typed Objective-C models with names, nesting and nullability inferred for you.

JSON to Crystal

Paste a JSON or XML sample — the format is auto-detected — and get typed Crystal models with names, nesting and nullability inferred for you.

JSON to Elm

Paste a JSON or XML sample — the format is auto-detected — and get typed Elm models with names, nesting and nullability inferred for you.

JSON to Haskell

Paste a JSON or XML sample — the format is auto-detected — and get typed Haskell models with names, nesting and nullability inferred for you.

JSON to Pike

Paste a JSON or XML sample — the format is auto-detected — and get typed Pike models with names, nesting and nullability inferred for you.

JSON to JavaScript PropTypes

Paste a JSON or XML sample — the format is auto-detected — and get typed JavaScript PropTypes models with names, nesting and nullability inferred for you.

Java Formatter

Fast structural beautification for Java — braces aligned, nesting indented, readable in one click.

C# Formatter

Instant structural beautification for C# — paste any fragment, get readable indentation back.

Java Escape

Java-ready string literals from any text — full \uXXXX Unicode escaping for clean, ASCII-safe source files.

.NET Escape

C#-ready string literals from any text — standard escapes plus \uXXXX Unicode, decoded back just as easily.