Interactive, beginner-friendly — learn by doing, not just reading.
7 lessons • ~20 min • No setup needed
JSON stands for JavaScript Object Notation. Despite the name, it is used by almost every programming language — Python, Go, Rust, Java, Swift — to store and exchange data.
.json file in any text editor and understand itHere is what a server might return when you request a user profile:
Notice the pattern: everything is a key–value pair. The key is always a string in double quotes. The value can be one of 6 types — you will learn all of them in the next lesson.
JSON has exactly 6 data types. Every value in any JSON document is one of these.
true or false, lowercase'like this' are not valid in JSON. You must always use double quotes for strings and keys.
{
"product": "Widget Pro",
"price": 29.99,
"in_stock": true,
"discount": null,
"sizes": ["S", "M", "L", "XL"],
"dimensions": {
"width": 10,
"height": 5
}
}
| Key | Value | Type |
|---|---|---|
"product" | "Widget Pro" | string |
"price" | 29.99 | number |
"in_stock" | true | boolean |
"discount" | null | null |
"sizes" | ["S","M","L","XL"] | array |
"dimensions" | { … } | object |
What type is the value false?
JSON is strict. One missing comma or an extra quote will make the entire document invalid. Here are the rules you must know.
// ❌ Invalid
{ name: "Alice" }
{ 'name': "Alice" }
// ✅ Valid
{ "name": "Alice" }
// ❌ Invalid (trailing comma after last item)
{
"a": 1,
"b": 2,
}
// ✅ Valid
{
"a": 1,
"b": 2
}
JSON does not support // comments or /* block comments */. Comments in this tutorial are for explanation only — never paste them into real JSON.
{
"greeting": "Say \"hello\" to her",
"path": "C:\\Users\\Alice",
"newline": "Line 1\nLine 2"
}
| Escape | Meaning |
|---|---|
\" | Double quote |
\\ | Backslash |
\n | New line |
\t | Tab |
\uXXXX | Unicode character |
// ❌ Invalid
{ "count": "42" } // This is a string, not a number
{ "pi": Infinity } // Not supported
{ "hex": 0xFF } // Not supported
// ✅ Valid
{ "count": 42, "pi": 3.14159, "exp": 1.5e10 }
Which of these is valid JSON?
{ name: "Bob", age: 30, }{ 'name': 'Bob', 'age': 30 }{ "name": "Bob", "age": 30 }{ "name": "Bob", "age": 30, }Objects and arrays are the two container types in JSON. Together they let you represent any data structure, no matter how complex.
An object is a comma-separated list of "key": value pairs, wrapped in { }. Keys must be unique within one object.
An array is a comma-separated list of values, wrapped in [ ]. Items can be any type, including other arrays or objects.
Objects can contain arrays. Arrays can contain objects. This nesting can go as deep as needed.
{
"team": "Rockets",
"members": [
{ "name": "Alice", "role": "lead" },
{ "name": "Bob", "role": "dev" }
],
"meta": {
"created": "2026-01-01",
"active": true
}
}
data.members[0].name → "Alice"data.meta.active → true
What is the value of data.members[1].role?
"lead""dev""Bob"undefinedWrite or paste any JSON below. The sandbox validates it in real time and shows you a formatted version — or an exact error message if something is wrong.
Each exercise below contains deliberately broken JSON. Fix it so it becomes valid. Click Check when you are done. A hint is available if you get stuck.
A printable, copy-paste reference for everything you have learned.
{}
[]
null
"Hello, World!" "Line 1\nLine 2" "Say \"hi\"" "Path: C:\\Users"
42 -7 3.14 1.5e10 -2.3E-4
true false null
{
"key": "value",
"num": 42
}
[1, "two", true, null]
[
{"id": 1},
{"id": 2}
]
{
"user": {
"name": "Alice",
"roles": ["admin"]
}
}
{ key: "v" } ❌
{ 'k': 'v' } ❌
{ "k": "v", } ❌
// comment ❌
{ "k": True } ❌
// Parse
JSON.parse('{"a":1}')
// Stringify
JSON.stringify({a:1})
// Pretty
JSON.stringify(obj, null, 2)
import json
# Parse
json.loads('{"a":1}')
# Stringify
json.dumps({"a":1})
You have completed the JSON Playground & Tutorial. Go build something with your new superpower.