What Is JSON?
JSON stands for JavaScript Object Notation. It's a simple, text-based format for storing and sharing data between programs, websites, and servers. If you've ever used a website that loads data dynamically โ like a news feed, a product listing, or a weather app โ JSON was almost certainly involved behind the scenes.
Our free JSON Formatter helps you read, format, and validate JSON instantly, even if you've never written a line of code.
Why Was JSON Created?
In the early 2000s, web applications needed a way to send data between a browser and a server without reloading the entire page. XML was the main option at the time, but it was verbose and difficult to work with in JavaScript. JSON was designed as a simpler alternative that JavaScript could understand natively โ which made it immediately popular with web developers. Today, JSON is the dominant data format for APIs, configuration files, and data storage across virtually every programming language.
What Does JSON Look Like?
Here's a simple example of JSON:
`json
{
"name": "Sarah Johnson",
"age": 34,
"email": "sarah@example.com",
"isActive": true,
"hobbies": ["photography", "hiking", "cooking"],
"address": {
"city": "Austin",
"country": "USA"
}
}
`
Even without any programming knowledge, you can probably understand what this means. Sarah Johnson is 34 years old, her email is sarah@example.com, she's an active user, and she has three hobbies. Her address is also included as a nested object.
The Building Blocks of JSON
JSON is built from just a handful of pieces:
Key-Value Pairs
The most basic unit:"name": "Sarah". The key is always a string in double quotes. The value can be several types.Data Types in JSON
| Type | Example | Notes |
|---|---|---|
| String | "hello" | Always in double quotes |
| Number | 42 or 3.14 | No quotes, supports decimals |
| Boolean | true or false | Lowercase only |
| Null | null | Means "no value" |
| Array | ["a", "b", "c"] | List of values in square brackets |
| Object | {"key": "value"} | Nested data in curly braces |
Arrays
An array is a list:["photography", "hiking", "cooking"]. Arrays can contain any data type โ even other arrays or objects.Objects
An object groups related data:{"city": "Austin", "country": "USA"}. Objects can nest inside other objects, which is how complex data structures are built.Where Is JSON Used?
JSON appears in almost every modern software system:
- Web APIs โ When you check the weather on an app, the app sends a request to a weather API, which responds with a JSON object containing temperature, conditions, forecast, etc.
- Configuration files โ Tools like VS Code, npm, and GitHub Actions store their settings in
.jsonfiles
- Databases โ Modern databases like MongoDB store records in a JSON-like format
- Mobile apps โ iOS and Android apps use JSON to sync data with their backend servers
- E-commerce โ Product catalogs, inventory data, and order details are commonly exchanged as JSON
JSON vs. Other Data Formats
| Format | Human Readable | Common Use | Verbosity | |---|---|---|---| | JSON | Yes | APIs, web, apps | Low | | XML | Somewhat | Legacy systems, RSS feeds | High | | CSV | Yes | Spreadsheets, exports | Low (flat data only) | | YAML | Yes | Config files (Docker, CI/CD) | Very low | | Binary | No | High-performance systems | Minimal |
JSON wins on the combination of being easy to read, compact, and universally supported.
How to Read JSON (Even as a Non-Developer)
Real-world JSON often arrives as a single long line with no spaces โ called minified JSON. It looks like this:
`
{"name":"Sarah Johnson","age":34,"email":"sarah@example.com","isActive":true}
`
This is impossible to read at a glance. That's where a JSON formatter helps. Paste this into our JSON Formatter and it instantly becomes:
`json
{
"name": "Sarah Johnson",
"age": 34,
"email": "sarah@example.com",
"isActive": true
}
`
The data is identical โ formatting just makes it readable.
Common JSON Mistakes
Even experienced developers make these errors:
- Single quotes instead of double quotes โ JSON requires
"double quotes"for all strings and keys. Single quotes'like this'are not valid JSON.
- Trailing commas โ
{"a": 1, "b": 2,}โ that comma after2breaks the JSON. The last item in any object or array must not have a trailing comma.
- Unquoted keys โ
{name: "Sarah"}is valid JavaScript but invalid JSON. Keys must always be in quotes:{"name": "Sarah"}.
- Comments โ JSON does not support comments.
// This is a commentwill cause an error.
The JSON Formatter catches all of these errors and tells you exactly where the problem is.
How to Validate JSON
Validation checks whether your JSON is correctly written (syntactically valid) and will actually work when used. To validate JSON:
1. Copy your JSON 2. Open the JSON Formatter 3. Paste it in 4. If there are errors, the tool highlights them with the line number and a description 5. If the JSON is valid, the formatted output appears with no errors
Frequently Asked Questions
Is JSON only for JavaScript? No. Despite the name, JSON is language-independent. It's used with Python, Ruby, PHP, Java, Swift, Go, Rust, and virtually every other programming language. The name is historical โ it was invented for JavaScript but quickly became universal.
What's the difference between JSON and a regular text file? A text file can contain anything. JSON text follows specific rules โ it must have a valid structure with properly quoted keys, correct data types, and no syntax errors. A program reading JSON expects those rules to be followed. A JSON Formatter checks these rules for you.
What does "invalid JSON" mean? It means the JSON contains a syntax error โ a missing quote, an extra comma, an unquoted key, or some other rule violation. Invalid JSON cannot be parsed by any program, which causes errors in apps and APIs. Always validate your JSON before using it.
Can JSON contain images or files? Not directly. JSON is text-only. However, you can encode binary data (like images) as a Base64 string and include that string inside a JSON value. The recipient then decodes it. This is common in APIs that need to transfer files alongside other data.