What is JSON — A Simple Explanation for Beginners
Published: May 18, 2025 · 6 min read
If you're learning web development, working with APIs, or handling data in any programming language, you'll encounter JSON almost immediately. It's everywhere — and for good reason. This guide explains what JSON is, why it exists, and how to use it.
JSON Stands for JavaScript Object Notation
JSON (pronounced "jay-son") is a text-based format for representing structured data. Despite its name referencing JavaScript, JSON is completely language-independent. Every major programming language — Python, Java, C#, Go, Ruby, PHP, Swift, Kotlin — can read and write JSON natively.
JSON was created by Douglas Crockford in the early 2000s as a lightweight alternative to XML. It quickly became the standard data format for web APIs because it's simple, compact, and easy for both humans and machines to work with.
JSON Syntax Rules
JSON has a small set of strict rules:
- Data is organized in key-value pairs
- Keys must be double-quoted strings (no single quotes)
- Values can be: strings, numbers, booleans (
true/false),null, arrays, or objects - Objects are wrapped in curly braces
{} - Arrays are wrapped in square brackets
[] - Items are separated by commas (no trailing comma allowed)
- No comments are allowed
A Simple JSON Example
This single JSON document contains strings, a number, a boolean, an array of strings, a nested object, and an array of objects. JSON can represent virtually any data structure by combining these building blocks.
JSON Data Types
| Type | Example | Notes |
|---|---|---|
| String | "hello world" | Must use double quotes |
| Number | 42, 3.14, -7 | Integer or float, no quotes |
| Boolean | true, false | Lowercase only |
| Null | null | Represents empty/missing value |
| Array | [1, 2, 3] | Ordered list of values |
| Object | {"key": "value"} | Unordered key-value pairs |
Where is JSON Used?
- REST APIs — nearly every modern API sends and receives JSON
- Configuration files — package.json (Node.js), tsconfig.json (TypeScript), settings.json (VS Code)
- Databases — MongoDB stores documents as JSON, PostgreSQL has JSONB columns
- Web Storage — localStorage and sessionStorage use JSON strings
- Data exchange — between microservices, mobile apps, and web clients
- Webhooks — Stripe, GitHub, Slack all send JSON payloads
JSON vs JavaScript Objects
While JSON looks like JavaScript object syntax, there are important differences:
- JSON keys must be quoted — JS objects don't require it
- JSON doesn't support functions, dates, or undefined
- JSON doesn't allow comments
- JSON doesn't allow trailing commas
- JSON is always a string — it needs to be parsed into an object
Working with JSON in Code
JavaScript:
Python:
Try It Yourself
Want to practice with JSON? Try our free tools:
- JSON Formatter — paste JSON and see it beautifully formatted
- JSON Tree Viewer — visualize JSON as an interactive tree
- Fix JSON — automatically repair broken JSON