TEXT & DEVELOPER GUIDE

What Is JSON? A Beginner's Guide With Examples

Priya Sharma(Product & Tools Lead)•Published: 2026-10-08•Updated: 2026-10-08•5 min read
Executive Summary

JSON (JavaScript Object Notation) is a lightweight, human-readable data format used to transmit information between web servers and browser clients. It stores data in key-value pairs and arrays, using strict syntax rules like double quotes around keys and no trailing commas.

Interactive Calculation Tool

Calculate your own numbers with our JSON Formatter & Validator

Instant calculations with real-time sliders and full schedules.

Open JSON Formatter & Validator

Quick Answer: What Is JSON?

JSON (JavaScript Object Notation, pronounced "JAY-sahn") is a standardized text format used to store and exchange structured data. Whenever you check the weather on your phone, log in to an app, or load a modern website, the server sends data to your device formatted as JSON. Here is a simple real-world JSON example representing a user profile: { "name": "Priya Sharma", "age": 28, "isSubscribed": true, "skills": ["JavaScript", "Python", "SQL"] } JSON is language-independent: while derived from JavaScript, virtually every programming language (Python, Java, C#, PHP, Go) has built-in tools to read and write JSON.

The 6 Supported JSON Data Types

JSON is deliberately simple and supports only six fundamental data types: 1. String: Text enclosed in double quotes (e.g., "Hello, World!"). 2. Number: Integers or floating-point numbers without quotes (e.g., 42, 3.14159, -12). 3. Boolean: Either true or false (lowercase, no quotes). 4. Null: Represents an empty or absent value (null, lowercase, no quotes). 5. Array: An ordered list of values enclosed in square brackets (e.g., ["apple", "banana", "orange"]). 6. Object: An unordered collection of key-value pairs enclosed in curly braces {}.

Parsing JSON in JavaScript and Python

Working with JSON in code is straightforward across major programming ecosystems: In JavaScript: • Parsing (Converting raw JSON text into an in-memory JS object): const data = JSON.parse('{"status": "success", "count": 10}'); console.log(data.status); // "success" • Serializing (Converting an in-memory JS object into a JSON string): const jsonString = JSON.stringify({ name: "Amit", role: "Developer" }); In Python: import json • Parsing string to dictionary: user = json.loads('{"active": true, "id": 101}') • Converting dictionary to JSON string: payload = json.dumps({"active": True, "id": 101})

JSON vs XML vs YAML: When to Use Each

Different formats excel in different software architectures: • JSON: Best for web APIs and microservice communication. Fast to serialize, compact, and natively supported by web browsers. • YAML: Best for human-edited configuration files (such as GitHub Actions or Kubernetes manifests). Uses clean indentation without braces or quotation clutter. • XML: Used primarily in legacy enterprise software, banking SOAP protocols, and document markup (HTML/SVG). More verbose due to required opening and closing tags (<user></user>).

JSON Schema: Enforcing Data Contracts in Production APIs

In enterprise software and backend microservices, developers use JSON Schema to mathematically validate incoming payloads before writing data to databases. Here is an example schema that validates a user registration request: { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "username": { "type": "string", "minLength": 3 }, "age": { "type": "integer", "minimum": 18 }, "email": { "type": "string", "format": "email" } }, "required": ["username", "email"] } If a client sends an age under 18 or omits the email address, the API server rejects the request immediately with a clear 400 Bad Request error, preventing corrupted data from entering the database.

JSON Security Best Practices: Avoiding Injections and DoS

While JSON is safer than executable script formats, developers must guard against specific security vulnerabilities: 1. Prototype Pollution in JavaScript: When parsing untrusted JSON containing keys like "__proto__" or "constructor", malicious users can alter base JavaScript object prototypes. Modern applications use object sanitizers or Map structures to block prototype injection. 2. JSON Parsing Denial of Service (Billion Laughs / Deep Nesting): Payloads with thousands of deeply nested brackets {{{{{...}}}}} can cause recursive parser stack overflow crashes. Production servers enforce maximum payload size limits (e.g. 1 MB) and maximum depth limits.

4 Strict Syntax Rules You Must Follow

Unlike flexible programming languages, JSON parsers fail if you violate strict syntax rules: 1. Double Quotes Only: Keys and strings MUST use double quotes ("key": "value"). Single quotes ('key': 'value') will crash the parser. 2. No Trailing Commas: In JavaScript, { "a": 1, } is allowed. In JSON, a trailing comma after the last item is a fatal syntax error. 3. No Comments Allowed: JSON does not permit // or /* */ comments. 4. No Functions or Dates: JSON only carries raw serializable data; dates are formatted as ISO strings like "2026-10-08T12:00:00Z".

Common JSON Syntax Errors and How to Fix Them

When APIs return "Unexpected token in JSON at position...", it is usually caused by: • Missing quotation marks around object keys: { name: "Amit" } ❌ → { "name": "Amit" } ✅ • Trailing commas in arrays: [1, 2, 3,] ❌ → [1, 2, 3] ✅ • Unescaped special characters: Inside strings, quotes must be escaped as \" and newlines as \n.

Validate and Prettify JSON in Your Browser

Instead of squinting at thousands of lines of minified API data, paste your code into our free QuickCalc JSON Formatter to auto-indent, format, and pinpoint syntax errors instantly with 100% client-side privacy.

Disclaimer: JSON parsing requires strict adherence to RFC 8259 specifications. Formatting tools should run client-side to protect proprietary data.

Frequently Asked Questions

What is JSON used for?

JSON is primarily used for transmitting data between web servers and client applications (REST APIs), storing configuration files, and serializing database records.

Can JSON have comments?

No. The official JSON specification (RFC 8259) does not support comments to ensure consistent cross-platform parsing.

What is the difference between JSON and XML?

JSON is shorter, easier for humans to read, faster to parse, and maps directly to native data structures in modern programming languages, whereas XML uses verbose closing tags.

Where can I format and validate JSON online?

You can validate and prettify minified JSON code using our free QuickCalc JSON Formatter.