What is JSON? Complete Beginner's Guide
May 26, 20268 min read
What is JSON?
JSON (JavaScript Object Notation) is a lightweight data-interchange format that has become the de facto standard for data exchange on the web. It is easy for humans to read and write, and easy for machines to parse and generate.
JSON Syntax Basics
JSON data is written as key-value pairs. Keys must be strings wrapped in double quotes, and values can be:
- Strings:
"hello world" - Numbers:
42,3.14 - Booleans:
true,false - Null:
null - Arrays:
[1, 2, 3] - Objects:
{"key": "value"}
Example
{
"name": "John Doe",
"age": 30,
"isActive": true,
"skills": ["JavaScript", "Python", "SQL"],
"address": {
"city": "New York",
"country": "USA"
}
}
Why JSON is Popular
- Human-readable: The syntax is simple and intuitive
- Language-independent: Almost every programming language has JSON support
- Lightweight: Minimal overhead compared to XML
- Native JavaScript support: Parsed natively with
JSON.parse()and serialized withJSON.stringify()
Common Uses of JSON
- APIs: REST APIs return data in JSON format
- Configuration files: Package managers like npm use
package.json - Data storage: NoSQL databases like MongoDB store data in JSON-like format
- Web sockets: Real-time communication often uses JSON messages
JSON vs Other Formats
See our detailed JSON vs XML comparison to understand when to use each format.
Try It Yourself
Use our free JSON Formatter to format, validate, and minify your JSON data online.