Complete JSON guide for beginners. Learn JSON syntax, data types, structure, and examples. Reference for developers, students, and anyone working with JSON.
Last updated: March 2026 • JSON Version: RFC 8259
JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format. Despite the name, JSON is language-independent and works with virtually every programming language.
JSON was created by Douglas Crockford in the early 2000s as a simpler alternative to XML. Today, JSON is the standard for APIs, configuration files, and data storage.
Key Facts:
JSON is built on two structures:
{} hold objects[] hold arraysJSON supports six data types:
Text data, enclosed in double quotes:
Valid String Characters:
a-z, A-Z0-9!@#$%^&*()_+-=[]{}|;:',.<>?\uXXXXEscape Sequences:
\" - Double quote\\ - Backslash\/ - Forward slash\b - Backspace\f - Form feed\n - New line\r - Carriage return\t - Tab\uXXXX - Unicode characterNumeric values, can be integer or floating-point:
Valid Number Formats:
42, -7, 03.14, -0.001, 1.01.23e4, 1.23E-40.42 (not .42)Logical values, either true or false:
Ordered list of values, enclosed in square brackets:
Unordered collection of key/value pairs, enclosed in curly braces:
Represents empty or non-existent value:
Note: null is different from false, 0, or empty string "".
Example - Valid JSON:
Example - Valid JavaScript Object (Not JSON):
REST APIs return JSON as the standard response format:
Application settings in JSON format:
NoSQL databases like MongoDB store data as JSON-like documents:
"firstName", not "first_name""createdAt", not "date1""2026-03-04T12:00:00Z"Practice your JSON skills with our free online editor. Features include real-time validation, tree view, graph visualization, and formatting tools—all without registration.
References: RFC 8259 (JSON specification), ECMA-404, MDN JSON documentation.
Learn JSON by doing. Our free online editor includes real-time validation, tree view, graph visualization, and formatting tools to help you master JSON—all without registration.
Try JSON Visualiser{ "name": "John Doe", "age": 30, "isStudent": false, "address": { "street": "123 Main St", "city": "New York", "country": "USA" }, "hobbies": ["reading", "coding", "hiking"]}{ "name": "John Doe", "email": "john@example.com", "message": "Hello, World!"}{ "age": 30, "price": 99.99, "negative": -10, "scientific": 1.23e4, "zero": 0}{ "isActive": true, "isDeleted": false, "hasPermission": true}{ "numbers": [1, 2, 3, 4, 5], "names": ["Alice", "Bob", "Charlie"], "mixed": [42, "hello", true, null, { "key": "value" }], "nested": [ [1, 2], [3, 4], [5, 6] ]}{ "person": { "name": "John", "age": 30 }, "empty": {}, "nested": { "level1": { "level2": { "value": "deep" } } }}{ "middleName": null, "spouse": null, "address": null}{ "name": "John", "age": 30}{ "user": { "name": "John", "contact": { "email": "john@example.com", "phone": "+1-555-0123" } }}{ "users": [ { "id": 1, "name": "Alice" }, { "id": 2, "name": "Bob" }, { "id": 3, "name": "Charlie" } ]}{ "company": "Tech Corp", "founded": 2010, "employees": [ { "id": 1, "name": "Alice", "role": "Developer", "skills": ["JavaScript", "Python", "Go"], "projects": [ { "name": "Project A", "status": "completed" } ] } ], "departments": { "engineering": { "head": "Bob", "count": 15 }, "design": { "head": "Carol", "count": 5 } }}{ "name": "John", "age": 30, "active": true}{ name: "John", // Unquoted key age: 30, active: true, createdAt: new Date(), // Date object greet: function() {} // Function}// Parse JSON string to objectconst jsonString = '{"name": "John", "age": 30}';const obj = JSON.parse(jsonString);console.log(obj.name); // John// Convert object to JSON stringconst data = { name: "John", age: 30 };const jsonString = JSON.stringify(data, null, 2);import json# Parse JSON string to dictjson_string = '{"name": "John", "age": 30}'data = json.loads(json_string)print(data['name']) # John# Convert dict to JSON stringdata = {"name": "John", "age": 30}json_string = json.dumps(data, indent=2)<?php// Parse JSON string to array$json_string = '{"name": "John", "age": 30}';$data = json_decode($json_string, true);echo $data['name']; // John// Convert array to JSON string$data = ["name" => "John", "age" => 30];$json_string = json_encode($data, JSON_PRETTY_PRINT);?>import org.json.JSONObject;// Parse JSON stringString jsonString = "{\"name\": \"John\", \"age\": 30}";JSONObject obj = new JSONObject(jsonString);System.out.println(obj.getString("name")); // John// Create JSON stringJSONObject obj = new JSONObject();obj.put("name", "John");obj.put("age", 30);String jsonString = obj.toString(2); // pretty print{ "status": "success", "data": { "user": { "id": 123, "name": "John Doe", "email": "john@example.com" } }, "timestamp": "2026-03-04T12:00:00Z"}{ "app": { "name": "MyApp", "version": "1.0.0", "port": 3000 }, "database": { "host": "localhost", "port": 5432, "name": "myapp" }}{ "_id": "64f8c9e01234567890abcdef", "title": "Blog Post", "content": "This is the content...", "author": { "id": 123, "name": "John" }, "tags": ["tech", "programming", "json"], "createdAt": "2026-03-04T12:00:00Z"}