JSON Format Explained — A Practical Guide for Beginners
Last updated: December 29, 2025 · 10 min read
JSON (JavaScript Object Notation) is the most widely used data format on the web. If you work with APIs, databases, configuration files, or web applications, you'll encounter JSON daily. This guide explains the format from scratch with practical examples.
What Is JSON?
JSON is a lightweight text format for storing and transporting data. Despite the "JavaScript" in its name, JSON is language-independent — every major programming language (Python, Java, Go, Ruby, C#, PHP, and many more) can read and write JSON.
JSON was formalized by Douglas Crockford in the early 2000s and standardized as RFC 8259. Today it's the default format for REST APIs, NoSQL databases (MongoDB, CouchDB, Firebase), configuration files (package.json, tsconfig.json), and data interchange between services.
JSON Syntax Rules
JSON has simple, strict syntax rules:
- Data is organized in key-value pairs, separated by colons:
"key": "value" - Keys must be strings in double quotes — single quotes are not valid
- Values can be strings, numbers, booleans, null, arrays, or objects
- Pairs are separated by commas
- Objects are wrapped in curly braces
{} - Arrays are wrapped in square brackets
[] - No trailing commas — a comma after the last element is invalid
- No comments — JSON does not support
// commentsor/* blocks */
The Six JSON Data Types
1. String
A sequence of characters wrapped in double quotes. Supports escape sequences.
"Hello, World!" "Line one\nLine two" "Path: C:\\Users\\Documents" "Unicode: \u00e9"
2. Number
Integer or floating-point. No quotes. Supports scientific notation.
42 3.14 -17 2.998e8
3. Boolean
Either true or false (lowercase, no quotes).
true false
4. Null
Represents an empty or unknown value (lowercase, no quotes).
null
5. Array
An ordered list of values in square brackets. Values can be any type, including mixed types.
["apple", "banana", "cherry"] [1, 2, 3, 4, 5] [true, "hello", 42, null]
6. Object
An unordered collection of key-value pairs in curly braces.
{
"name": "Alice",
"age": 30,
"isActive": true,
"address": null
}
Nesting: JSON's Superpower
JSON values can be objects or arrays, which means you can nest structures to any depth. This is what makes JSON more expressive than flat formats like CSV.
{
"name": "Alice",
"age": 30,
"address": {
"street": "123 Main St",
"city": "New York",
"state": "NY",
"zip": "10001"
},
"hobbies": ["reading", "hiking", "photography"],
"education": [
{
"degree": "BS Computer Science",
"school": "MIT",
"year": 2017
},
{
"degree": "MS Data Science",
"school": "Stanford",
"year": 2019
}
]
}
Here, address is a nested object, hobbies is an array of strings, and education is an array of objects. This kind of structure would require multiple tables and joins in a relational database, but JSON represents it naturally in a single document.
Common Mistakes
These are the most frequent JSON syntax errors:
1. Using single quotes instead of double quotes
{'name': 'Alice'} — Invalid{"name": "Alice"} — Valid2. Trailing comma after the last element
{"a": 1, "b": 2,} — Invalid{"a": 1, "b": 2} — Valid3. Unquoted keys
{name: "Alice"} — Invalid{"name": "Alice"} — Valid4. Using undefined
{"value": undefined} — Invalid{"value": null} — Valid5. Comments in JSON
{"name": "Alice" // user name} — Invalid{"name": "Alice"} — Valid (JSON does not support comments)Working with JSON in Different Languages
JavaScript / TypeScript
// Parse JSON string to object
const data = JSON.parse('{"name": "Alice", "age": 30}');
// Convert object to JSON string
const json = JSON.stringify(data, null, 2);
// Fetch JSON from API
const response = await fetch('/api/users');
const users = await response.json();
Python
import json
# Parse JSON string
data = json.loads('{"name": "Alice", "age": 30}')
# Convert to JSON string
json_str = json.dumps(data, indent=2)
# Read from file
with open('data.json') as f:
data = json.load(f)
# Write to file
with open('output.json', 'w') as f:
json.dump(data, f, indent=2)
Command Line (jq)
# Pretty print JSON cat data.json | jq '.' # Extract a field cat data.json | jq '.[0].name' # Filter array elements cat data.json | jq '.[] | select(.age > 25)'
JSON vs Other Formats
| Format | Best For | JSON Advantage |
|---|---|---|
| XML | Enterprise systems, SOAP APIs | JSON is less verbose and easier to parse |
| CSV | Flat tabular data, spreadsheets | JSON supports nesting and data types |
| YAML | Config files (Docker, K8s) | JSON is stricter and less error-prone |
| TOML | Config files (Rust, Python) | JSON has broader ecosystem support |
| Protocol Buffers | High-performance RPC | JSON is human-readable without tooling |
Converting Table Data to JSON
If you have data in a spreadsheet (Excel, Google Sheets) or a CSV/TSV file and need to convert it to JSON, the fastest approach is to use an online converter. tab2json.com lets you paste tabular data directly and get valid JSON output instantly — no signup, no server uploads, completely browser-based.
For programmatic conversion, see our Excel to JSON Guide covering JavaScript, Python, and command-line approaches.
Summary
JSON is simple yet powerful. Its six data types (string, number, boolean, null, array, object) can represent virtually any data structure. Master the syntax rules — double-quoted keys, no trailing commas, no comments — and you'll avoid the most common pitfalls. When you need to convert tabular data into JSON, tools like tab2json.com make it a one-step process.