What Is JSON? A Beginner's Complete Guide With Examples
JSON is everywhere in modern computing — APIs, configuration files, databases, and log files all use it. If you're learning to code, working with web APIs, or just curious about what the weird brackets mean, this guide will make JSON completely clear. Then try the free Quill Tools JSON Formatter to work with JSON hands-on.
What Does JSON Stand For?
JSON stands for JavaScript Object Notation. It was created by Douglas Crockford in the early 2000s as a lightweight alternative to XML for exchanging data between web servers and browsers. Despite its name, JSON is language-independent and is supported natively by virtually every programming language today.
JSON Syntax Rules
JSON has only six data types and a small set of syntax rules:
- String — Text surrounded by double quotes:
"Hello, World!" - Number — Integer or decimal, no quotes:
42,3.14,-7 - Boolean — Exactly
trueorfalse(lowercase) - Null — Exactly
null(lowercase) - Array — An ordered list of values in square brackets:
[1, 2, 3] - Object — A collection of key-value pairs in curly braces:
{ "key": "value" }
A Complete JSON Example
{
"name": "Alice",
"age": 30,
"isEmployed": true,
"address": null,
"skills": ["JavaScript", "Python", "SQL"],
"contact": {
"email": "alice@example.com",
"phone": "+44 20 1234 5678"
}
}JSON vs XML
Before JSON, XML was the dominant data exchange format. JSON replaced XML for most web APIs because it is:
- Simpler — No opening/closing tags, no attributes vs. elements confusion
- Lighter — Significantly fewer bytes for equivalent data
- Native in JavaScript — Parsed with
JSON.parse()in every browser - Easier to read — Especially when formatted
XML is still preferred for complex document structures, namespaces, and legacy enterprise systems (SOAP APIs).
How to Read and Write JSON
JavaScript
// Parse JSON string → object
const obj = JSON.parse('{"name":"Alice","age":30}')
console.log(obj.name) // "Alice"
// Stringify object → JSON
const json = JSON.stringify(obj, null, 2)Python
import json
obj = json.loads('{"name":"Alice","age":30}')
print(obj["name"]) # Alice
json_str = json.dumps(obj, indent=2)Common JSON Mistakes
- Using single quotes instead of double quotes
- Adding a trailing comma after the last item
- Using
undefined,NaN, orInfinity(not valid JSON values) - Comments (
//or/* */) — JSON has no comment syntax - Forgetting quotes around string values
Frequently Asked Questions
Is JSON a programming language?
No. JSON is a data format, not a programming language. It can be read and written by virtually every programming language.
What is the difference between JSON and XML?
JSON is lighter, easier to read, and parsed natively in JavaScript. XML is more verbose but supports attributes and namespaces for complex documents.
Validate and format your JSON at Quill Tools JSON Formatter.
You May Also Like
Share this article