What Is JSON? A Beginner's Guide with a Free Formatter
JSON (JavaScript Object Notation) is a simple text format for storing and sharing data. Websites, apps and APIs use it every day to send information between servers and browsers. You do not need to be a programmer to read it, and once you understand a few rules, it becomes easy to work with.
A first example
{
"name": "Alex",
"age": 29,
"isStudent": false,
"skills": ["writing", "design"],
"address": {
"city": "Austin",
"state": "TX"
}
}
This describes a person. Each piece of data has a name (the key) and a value, written as "key": value.
The building blocks
- Object: a group of key-value pairs inside curly braces
{ }. - Array: an ordered list inside square brackets
[ ]. - String: text in double quotes, like
"hello". - Number: 29 or 3.14, with no quotes.
- Boolean:
trueorfalse. - Null:
nullmeans no value.
Rules that cause the most errors
- Keys and strings must use double quotes. Single quotes are not valid JSON.
- No trailing commas. A comma after the last item is an error.
- No comments. JSON does not allow
//or/* */comments. - Commas must separate items, and every opening bracket needs a closing bracket.
Reading a real-world example, step by step
Imagine an online store sends you this order. It looks long, but you can read it in four passes.
{
"orderId": 1042,
"paid": true,
"customer": { "name": "Maria Lopez", "email": "maria@example.com" },
"items": [
{ "sku": "MUG-01", "qty": 2, "price": 12.5 },
{ "sku": "TEE-07", "qty": 1, "price": 20 }
],
"coupon": null
}
- Find the outer shape. The first character is
{, so the whole thing is one object. - List the top-level keys. There are five: orderId, paid, customer, items and coupon.
- Identify each value type. orderId is a number, paid is a boolean, customer is a nested object, items is an array of objects, and coupon is null, meaning no coupon was used.
- Do the math you care about. Two mugs at 12.5 each is 25, plus one shirt at 20, so the item total is 45.
Notice that quotes matter. "qty": 2 is a number you can add up, while "qty": "2" is text that some programs will not add correctly.
Where you will see JSON
- API responses, such as weather data or product lists.
- Configuration files for apps and developer tools.
- Exporting and importing data between systems.
- Structured data for search engines (JSON-LD), like the markup that describes FAQs or articles on a page.
JSON vs CSV vs XML
| Format | Good for |
|---|---|
| JSON | Nested data, APIs, web apps |
| CSV | Simple tables and spreadsheets |
| XML | Older systems and documents with strict structure |
A rule of thumb: if your data fits neatly in rows and columns, like a contact list, CSV is smaller and opens in any spreadsheet. If one record contains other records, like an order that contains several items, JSON handles that shape naturally.
Fixing invalid JSON: a worked example
Here is a snippet that looks fine at a glance but will fail to parse.
{
'title': "Spring Sale",
"discount": 15,
"tags": ["clothing", "shoes",],
// ends March 31
"active": true
}
There are three separate problems:
- The key
'title'uses single quotes. Change it to"title". - The array has a trailing comma after
"shoes". Remove it. - The line starting with
//is a comment, which JSON does not allow. Delete it, or store the note as a real key such as"note": "ends March 31".
Validators usually report only the first error they hit, so fix one, run it again, and repeat until it passes. Always look at the line the message points to and the line just before it, because a missing comma is often reported on the following line.
Common mistakes beyond the basics
- Using unsupported values. JSON has no
undefined, noNaNand no date type. Dates are normally written as strings, such as"2025-05-09". - Leading zeros. A number like
007is invalid. If the leading zeros matter, as in a ZIP code such as 02134, store it as a string. - Repeating a key. Two identical keys in one object are technically allowed by some parsers but give unpredictable results. Use unique keys.
- Raw line breaks in strings. Write
\ninside a string instead of pressing Enter. - Unescaped quotes. To include a double quote inside text, write
\".
Quick takeaways
- JSON is plain text built from objects, arrays, strings, numbers, booleans and null.
- Use double quotes for every key and string.
- No trailing commas and no comments.
- Numbers without quotes can be calculated; numbers in quotes are text.
- Use CSV for flat tables and JSON for nested data.
- Run a validator whenever a file will not load.
How to fix invalid JSON
When something does not work, the error is usually a missing comma, an extra comma, a missing quote or an unclosed bracket. A formatter highlights the problem and shows where the data breaks. Paste your text into our free JSON Formatter and Validator to pretty-print it or minify it. It runs in your browser, so your data stays on your device.
Convert between formats
If your data starts in a spreadsheet, try the CSV to JSON Converter. If you need to include JSON data in a URL, an encoder like the URL Encoder and Decoder helps, and the Base64 Encoder is useful when a system expects text-safe data.
Frequently asked questions
Is JSON a programming language?
No. It is only a way of writing data down. It cannot run code, make decisions or do calculations by itself. Programs read it and then act on the values.
What is the difference between JSON and a JavaScript object?
They look similar, but JSON is stricter. In JSON every key must be in double quotes, and it cannot contain functions, comments or undefined values. A JavaScript object is something that lives inside a running program, while JSON is text that can be saved or sent.
Can I open a JSON file without special software?
Yes. A JSON file is plain text, so any text editor can open it. For long files, a formatter makes it far easier to read because it adds indentation and line breaks.
Why does my JSON look like one long line?
Many systems remove spaces and line breaks to make the file smaller. This is called minifying, and it does not change the meaning. Pretty-printing adds the spacing back so people can read it.
Security reminder
Do not paste passwords, API keys or private customer data into any online tool unless you trust it and understand where the data goes. Even for browser-based tools, it is a good habit to remove secrets first. Ready to practice? Open the JSON Formatter and Validator and try fixing the broken snippet above.
More free developer & data tools
Base64 Encoder and Decoder
Encode or decode text to and from Base64.
💻Password Generator
Generate strong random passwords securely in your browser.
💻UUID Generator
Generate random v4 UUIDs in bulk.