Developer Tools

JSON for Beginners: A Complete Guide to JSON Format and Validation

By Emmanuel Nyoni ยท 9 min read ยท Updated April 2026

JSON is the format that most APIs, config files, and web services use to exchange data. If you're building anything that talks to an API, you're dealing with JSON constantly. This guide explains what JSON is, how it works, what errors look like, and how to format and validate it instantly for free.

What JSON is

JSON is a lightweight, text-based format for storing and transmitting structured data. It was derived from JavaScript but is now language-independent, virtually every modern programming language can read and write JSON. It's used by APIs (like Stripe, PayFast, Google Maps), configuration files, database exports, webhook payloads, and much more.

The structure

JSON is built on two structures:

  • Objects, Key-value pairs wrapped in curly braces: {"name": "Emmanuel", "city": "Johannesburg"}
  • Arrays, Ordered lists wrapped in square brackets: ["PDF Compressor", "Invoice Maker", "QR Generator"]

Values in JSON can be: strings (in double quotes), numbers, booleans (true or false), null, objects, or arrays.

A Real-World Example

{
  "invoice": {
    "number": "INV-2026-001",
    "client": "Acme Corp",
    "currency": "ZAR",
    "items": [
      {"description": "Web Design", "qty": 1, "price": 15000},
      {"description": "Hosting Setup", "qty": 1, "price": 2500}
    ],
    "vat_rate": 0.15,
    "paid": false
  }
}

The most common errors

1. Trailing Comma

Valid in JavaScript, not in JSON. This is the most common error:

{"name": "Emmanuel", "city": "Johannesburg",}

The trailing comma after "Johannesburg" is invalid. Remove it.

2. Single Quotes Instead of Double Quotes

JSON requires double quotes for strings. Single quotes are not valid:

{'name': 'Emmanuel'}  โŒ
{"name": "Emmanuel"}  โœ“

3. Unquoted Property Names

{name: "Emmanuel"}   โŒ
{"name": "Emmanuel"} โœ“

4. Comments

JSON does not support comments of any kind, no //, no /* */. If you need to add notes to JSON, use a dedicated field like "_comment": "This is a note".

5. Missing Commas Between Items

{"name": "Emmanuel" "city": "Joburg"}   โŒ
{"name": "Emmanuel", "city": "Joburg"}  โœ“

6. Numbers in Quotes

If a value should be a number, don't put it in quotes, "price": "15000" is a string, not a number. "price": 15000 is a number.

Formatting

API responses and configuration files are often minified, all whitespace removed. This is efficient to transmit but impossible to read. Formatting (or "beautifying") adds consistent indentation to make the structure visible. FreeToolVault's JSON Formatter adds 2-space indentation automatically.

Minifying

Before sending JSON to an API or storing it in a database, strip out all the whitespace. This reduces payload size and speeds up transmission. Our JSON Formatter's Minify button does this in one click.

Validate JSON for free

  1. Go to FreeToolVault JSON Formatter
  2. Paste your JSON into the input field
  3. A green "โœ“ Valid JSON" message means your JSON is correctly formatted
  4. A red error message tells you exactly what's wrong and at which position
  5. Click "Format" to beautify, or "Minify" to compress
  6. Click "Copy" to copy the output to your clipboard

All JSON data stays in your browser, nothing is sent to any server. Safe for API keys, sensitive configuration, and production data.

JSON vs other formats

FormatBest ForHuman ReadableSupports Comments
JSONAPIs, web appsYesNo
XMLSOAP APIs, legacy systemsSomewhatYes
YAMLConfiguration files (Docker, K8s)YesYes
CSVSpreadsheet dataYesNo
Protocol BuffersHigh-performance APIsNoNo

{ } Format & Validate JSON Free โ†’