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
- Go to FreeToolVault JSON Formatter
- Paste your JSON into the input field
- A green "โ Valid JSON" message means your JSON is correctly formatted
- A red error message tells you exactly what's wrong and at which position
- Click "Format" to beautify, or "Minify" to compress
- 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
| Format | Best For | Human Readable | Supports Comments |
|---|---|---|---|
| JSON | APIs, web apps | Yes | No |
| XML | SOAP APIs, legacy systems | Somewhat | Yes |
| YAML | Configuration files (Docker, K8s) | Yes | Yes |
| CSV | Spreadsheet data | Yes | No |
| Protocol Buffers | High-performance APIs | No | No |