What Is JSON? A Beginner-Friendly Guide With Examples
The first time I opened a settings file for a small website project, I saw a wall of curly braces, quotation marks, and colons and assumed it was something only programmers could read. Ten minutes later I realized it was just a very tidy list of labels and values. I changed one setting, broke the whole site with a missing comma, and learned my first JSON lesson the hard way.
JSON is everywhere — in apps, websites, spreadsheets exports, smart-home devices, and AI tools. You don't need to be a developer to understand it. In this guide I'll explain JSON with everyday analogies, walk through its structure and syntax rules, cover the mistakes beginners hit most often, and show you how to validate JSON so you can catch problems before they break anything.
JSON explained with everyday analogies
JSON stands for JavaScript Object Notation. Despite the name, it isn't tied to JavaScript. It's a plain-text format for writing down structured information so that any program, in any language, can read it.
Think of a JSON object as a labeled form. A paper form has labels — Name, Email, Age — and a box next to each one. JSON works the same way: each label (called a key) is paired with a value.
Here's a simple example describing a person: {"name": "Amelia", "age": 29, "subscribed": true}
If an object is a form, an array is a shopping list: an ordered collection of items. For example: ["milk", "eggs", "bread"]. You can combine the two — a form that contains a list, or a list of forms — which is how JSON describes complex things like an order with several products.
Why JSON is so popular
- It's readable by humans and machines alike.
- It's lightweight, so it travels quickly between apps and servers.
- Almost every programming language can read and write it.
- Most web APIs — weather apps, payment systems, maps — send and receive data as JSON.
JSON structure and syntax rules
JSON is strict. Its rules are simple, but a single slip makes the whole file unreadable to a program. Here's everything you need.
The six value types
- String: text in double quotes, such as "London".
- Number: digits with no quotes, such as 42 or 3.14. No currency symbols or thousands separators.
- Boolean: true or false, lowercase, no quotes.
- Null: the word null, meaning "no value".
- Object: curly braces holding key–value pairs, such as {"city": "Toronto"}.
- Array: square brackets holding a list of values, such as [1, 2, 3].
The rules
- Keys must be strings in double quotes. {name: "Amelia"} is invalid; {"name": "Amelia"} is valid.
- Use double quotes only. Single quotes aren't allowed.
- Separate each key and value with a colon.
- Separate items with commas, but never put a comma after the last item.
- No comments. JSON has no way to add notes like // or /* */.
- Special characters in strings must be escaped with a backslash, such as \" for a quote or \n for a new line.
A fuller example
An online order might look like this: {"orderId": 1042, "customer": {"name": "Liam", "country": "AU"}, "items": [{"product": "Notebook", "qty": 2}, {"product": "Pen", "qty": 5}], "paid": true, "coupon": null}
Read it like a form: an order number, a customer (itself a small form), a list of items (each a small form), a paid flag, and an empty coupon field. Pasting that into our JSON Formatter spreads it across neat, indented lines so the structure is easy to see.
The most common errors beginners hit
- Trailing commas. {"a": 1, "b": 2,} fails because of the comma before the closing brace. This is the number-one JSON error.
- Single quotes. {'name': 'Amelia'} looks fine but is invalid.
- Unquoted keys. Copying from JavaScript code often leaves keys without quotes.
- Missing commas between items, especially after editing a long file by hand.
- Mismatched brackets. Every { needs a }, and every [ needs a ]. Deeply nested data makes this easy to miss.
- Comments left in the file. Some config tools accept them, but standard JSON doesn't.
- Smart quotes. Word processors and some chat apps turn " into curly quotes, which JSON rejects. Always edit JSON in a plain-text editor.
- Wrong value types. "true" in quotes is a string, not a boolean; "42" is text, not a number. Programs may treat them differently.
How to validate JSON
Validating JSON means checking that it follows the rules so a program can read it. The quickest way is to paste it into a validator that points to the exact problem.
- Open our JSON Formatter.
- Paste your JSON into the input box.
- Click Validate. If something's wrong, you'll see an error message describing the problem and roughly where it is.
- Fix the issue — usually a comma, quote, or bracket — and validate again.
- Once it's valid, use Format to make it readable or Minify to make it compact for sending.
Because the formatter runs in your browser, it's safe for JSON containing API keys, customer records, or internal settings. Many online validators send what you paste to their servers; this one doesn't.
Working with encoded data
Sometimes JSON contains Base64-encoded values, which look like long strings of random letters. You can decode those with our Base64 Encoder & Decoder to see what's inside.
Where you'll meet JSON in everyday life
You may already use JSON without realizing it. Knowing where it appears helps you recognize it — and fix it — when you need to.
- App and website settings. Code editors, browser extensions, and many games store preferences in .json files you can open in any text editor.
- Data exports. Services such as social networks, fitness trackers, and banking apps often let you download your data as JSON so you can see exactly what they hold about you.
- Website APIs. When a weather app shows tomorrow's forecast, it usually received that forecast as JSON from a server a moment earlier.
- No-code and automation tools. Zapier, Make, and similar tools pass data between apps as JSON, and their error messages often show raw JSON.
- AI tools. Many AI assistants and chatbots can output structured answers as JSON, and developers use JSON to send them instructions.
- Smart-home devices. Configuration files for home automation systems are frequently written in JSON or a close relative.
JSON's close relatives
You might also see YAML, which uses indentation instead of braces, and JSON Lines (.jsonl), where each line is a separate JSON object. CSV, the format spreadsheets export, is simpler: rows and columns with no nesting. JSON is the best choice when data has layers, such as an order that contains customers and items.
A safe way to edit JSON by hand
- Make a copy of the original file before changing anything.
- Edit in a plain-text or code editor, never a word processor.
- Change one thing at a time.
- Validate the result before saving it back where it belongs.
Following those four steps would have saved my website from that missing comma.
Quick answers to common questions
Is JSON a programming language?
No. It's a data format — a way of writing down information. It has no logic, loops, or instructions.
What's the difference between JSON and XML?
Both store structured data. XML uses opening and closing tags like HTML, while JSON uses braces and brackets. JSON is usually shorter and easier to read, which is why most modern APIs prefer it.
Can I open a JSON file in Excel?
Yes. Excel's Get Data feature can import JSON and turn it into a table, though deeply nested data may need some tidying.
What does "Unexpected token" mean?
It means the reader hit a character it didn't expect, often a trailing comma, a single quote, or a missing bracket just before the reported position.
Is it safe to paste private JSON into an online tool?
Only if the tool runs in your browser. Our formatter processes everything locally, so your data never leaves your device.