JSON for Beginners: What It Is and How to Use It
Published: December 20, 2025 · Updated: February 15, 2026
If you work with web technologies, APIs, or configuration files, you will encounter JSON almost daily. JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging structured data. Despite its name, JSON is language-independent and used across virtually every programming language and platform.
A Brief History
JSON was specified by Douglas Crockford in the early 2000s as a simpler alternative to XML. Its syntax is derived from JavaScript object literals, but it quickly became the dominant data interchange format on the web because of its simplicity, readability, and compact size. Today it is standardised as ECMA-404 and described in RFC 8259.
JSON Syntax at a Glance
JSON is built on two structures:
- Objects: An unordered collection of key-value pairs, written as
{"key": "value"}. Keys must be strings in double quotes. - Arrays: An ordered list of values, written as
["a", "b", "c"].
JSON supports six value types:
- String — text wrapped in double quotes:
"hello" - Number — integer or floating point:
42,3.14 - Boolean —
trueorfalse - Null —
null - Object — nested
{...} - Array — nested
[...]
Example
{
"name": "Alice",
"age": 30,
"isStudent": false,
"courses": ["Mathematics", "Physics"],
"address": {
"city": "London",
"postcode": "EC1A 1BB"
}
}
Common Syntax Errors
JSON is strict about syntax. The most frequent mistakes include:
- Trailing commas:
{"a": 1,}is invalid. The last item must not have a comma after it. - Single quotes:
{'a': 1}is invalid. JSON requires double quotes. - Unquoted keys:
{name: "Alice"}is invalid. Keys must be in double quotes. - Comments: JSON does not support comments. Use
// noteor/* block */and the parser will reject the file. - Missing colons or braces: Every key must be followed by a colon, and every opening brace or bracket needs a matching close.
When you encounter a cryptic "Unexpected token" error, paste your JSON into our JSON Formatter — it will highlight the exact line and character where the error occurs.
Where JSON Is Used
Web APIs
REST APIs almost universally use JSON for request and response bodies. When your browser fetches data from a server — weather forecasts, user profiles, search results — the response is usually JSON.
Configuration Files
Tools like VS Code (settings.json), npm (package.json),
and many others use JSON for configuration because it is easy for both humans and
machines to read and write.
Data Storage
NoSQL databases like MongoDB store documents in a JSON-like format (BSON). Many applications also use JSON files as lightweight databases for prototyping or small-scale storage.
Data Exchange
When systems written in different languages need to communicate, JSON serves as a universal format. A Python backend can send JSON to a JavaScript frontend, which can send it to a Java microservice — all without compatibility issues.
JSON vs. Other Formats
| Feature | JSON | XML | YAML |
|---|---|---|---|
| Readability | Good | Moderate | Excellent |
| File size | Compact | Verbose | Compact |
| Comments | No | Yes | Yes |
| Schema validation | JSON Schema | XSD | Limited |
| Native JS support | Yes | No | No |
Working with JSON
Here are practical tasks you can do with our tools:
- Format and validate: Paste raw JSON into the JSON Formatter to pretty-print it with proper indentation and catch syntax errors.
- View as a table: Use the JSON Table Viewer to explore arrays of objects in a spreadsheet-like interface.
- Convert formats: Switch between JSON, YAML, XML, and CSV with the Data Converter.
Tips for Writing Clean JSON
- Use consistent indentation (2 or 4 spaces) for readability.
- Keep key names descriptive but concise:
"firstName"not"fn". - Use camelCase for key names — it is the most common convention.
- Validate your JSON before sending it to an API or committing it to source control.
- When JSON grows complex, consider using JSON Schema to document and enforce the structure.
Summary
JSON is the universal language of data exchange on the web. Its simplicity makes it easy to learn, but its strict syntax means small mistakes can cause parsing failures. Bookmark our JSON Formatter for quick validation, and use the resources above to deepen your understanding of this essential format.