← Home · Blog

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

{ "name": "Sarah Johnson", "age": 28, "email": "sarah@example.com", "isActive": true, "hobbies": ["reading", "coding", "hiking"], "address": { "street": "456 Oak Avenue", "city": "San Francisco", "state": "CA", "zip": "94102" }, "phoneNumbers": [ {"type": "home", "number": "555-1234"}, {"type": "work", "number": "555-5678"} ] }

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

TypeExampleNotes
String"hello world"Must use double quotes
Number42, 3.14, -7Integer or float, no quotes
Booleantrue, falseLowercase only
NullnullRepresents 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:

// Parse JSON string → object const data = JSON.parse('{"name": "Alice", "age": 30}'); console.log(data.name); // "Alice" // Convert object → JSON string const json = JSON.stringify(data, null, 2); console.log(json); // formatted JSON

Python:

import json # Parse JSON string → dictionary data = json.loads('{"name": "Alice", "age": 30}') print(data["name"]) # "Alice" # Convert dictionary → JSON string json_str = json.dumps(data, indent=2)

Try It Yourself

Want to practice with JSON? Try our free tools:

More Articles

How to Format JSON — A Complete Beginner's Guide

5 Common JSON Errors and How to Fix Them

JSON vs XML vs YAML — When to Use Which

How to Compare Two JSON Files

← All Articles · Home · About · Privacy Policy