JSON (JavaScript Object Notation) is the most popular data interchange format on the web. Whether you're building APIs, configuring applications, or working with data, understanding JSON is essential for modern developers.
JSON (pronounced "Jason") is a lightweight, text-based data format that's easy for humans to read and write, and easy for machines to parse and generate. Created in the early 2000s, JSON has become the de facto standard for web APIs and configuration files.
JSON syntax follows a few simple rules:
{
"name": "John Doe",
"age": 30,
"city": "New York"
}
Multiple properties are separated by commas. Important: No comma after the last item!
Objects are enclosed in {} and contain key-value pairs.
Arrays are enclosed in [] and contain ordered values.
JSON supports six data types:
| Data Type | Description | Example |
|---|---|---|
| String | Text enclosed in double quotes | "Hello World" |
| Number | Integer or decimal (no quotes) | 42, 3.14 |
| Boolean | True or false (no quotes) | true, false |
| Null | Represents no value | null |
| Object | Collection of key-value pairs | {"key": "value"} |
| Array | Ordered list of values | [1, 2, 3] |
{
"website": "JSONXPath",
"active": true,
"users": 1000,
"rating": 4.95,
"premium": false,
"nextUpdate": null,
"features": ["validation", "formatting", "search"],
"contact": {
"email": "info@agenscrape.co.uk",
"website": "https://jsonxpath.com"
}
}
JSON objects are collections of key-value pairs enclosed in curly braces {}.
{
"firstName": "Jane",
"lastName": "Smith",
"age": 28
}
{
"user": {
"name": "John Doe",
"address": {
"street": "123 Main St",
"city": "New York",
"country": "USA"
}
}
}
Arrays store ordered lists of values enclosed in square brackets [].
{
"colors": ["red", "green", "blue"],
"numbers": [1, 2, 3, 4, 5],
"mixed": [true, 42, "text", null]
}
{
"users": [
{
"id": 1,
"name": "Alice",
"active": true
},
{
"id": 2,
"name": "Bob",
"active": false
}
]
}
{"name": "John", "age": 30}
// ❌ Invalid - must use double quotes
{'name': 'John'}
// ❌ Invalid - no comma after last item
{
"name": "John",
"age": 30,
}
// ❌ Invalid - keys must be quoted
{name: "John"}
// ❌ Invalid - JSON doesn't support comments
{
"name": "John", // This will cause an error
"age": 30
}
Always validate your JSON to catch errors early. Use JSONXPath's free validator to check your JSON syntax instantly.
| Feature | JSON | XML |
|---|---|---|
| Readability | Easier to read | More verbose |
| File Size | Smaller | Larger |
| Parsing Speed | Faster | Slower |
| Data Types | Built-in types | Everything is a string |
| Arrays | Native support | Complex workarounds |
{
"status": "success",
"data": {
"user": {
"id": 12345,
"username": "johndoe",
"email": "john@example.com",
"verified": true
}
},
"timestamp": "2025-01-20T10:30:00Z"
}
{
"app": {
"name": "JSONXPath",
"version": "2.0.0",
"environment": "production"
},
"database": {
"host": "localhost",
"port": 5432,
"name": "myapp_db"
},
"features": {
"validation": true,
"formatting": true,
"analytics": true
}
}
Try our free online JSON viewer, validator, and formatter. Perfect for learning and debugging!
Start Using JSONXPath Free →JSON is a powerful, versatile data format that every developer should master. With its simple syntax and universal support, it's the perfect choice for APIs, configuration files, and data exchange.
Remember to: