Back to Blog
Developer Tools

What is JSON? A Beginner's Guide with Examples

Hafiz Hanif May 3, 2025 8 min read

JSON is the language of the modern web. Every API, every app, every database exchange uses it. Here's a plain-English explanation with real examples.

What is JSON? A Beginner's Guide with Examples

If you've ever worked with an API, opened a config file, or looked at browser developer tools, you've probably seen JSON. It's everywhere — and for good reason. JSON is the universal language that web applications use to talk to each other.

But what exactly is it? And how do you read, write, and format it? This guide covers everything you need to know, from the absolute basics to common errors and how to fix them.


What Does JSON Stand For?

JSON stands for JavaScript Object Notation. It was originally derived from JavaScript, but today it's used by virtually every programming language — Python, PHP, Java, Go, Ruby, C#, and more.

It was designed to be:

  • Lightweight — minimal syntax, small file sizes
  • Human-readable — easy to read and write by hand
  • Machine-parseable — fast and easy for computers to process

What Does JSON Look Like?

Here's a simple JSON example representing a user:

{
  "name": "Sarah Johnson",
  "age": 29,
  "email": "sarah@example.com",
  "isPremium": true,
  "tags": ["writer", "blogger", "seo"],
  "address": {
    "city": "London",
    "country": "UK"
  }
}

That's it. JSON is made up of key-value pairs wrapped in curly braces {}.


JSON Data Types

JSON supports exactly six data types:

1. String

Text wrapped in double quotes.

"name": "ToolsMadeEasy"

2. Number

Integer or decimal. No quotes.

"age": 25,
"price": 9.99

3. Boolean

Either true or false. No quotes.

"isActive": true,
"isDeleted": false

4. Null

Represents an empty or unknown value.

"middleName": null

5. Array

An ordered list of values in square brackets [].

"colors": ["red", "green", "blue"]

6. Object

A nested set of key-value pairs in curly braces {}.

"address": {
  "street": "123 Main St",
  "city": "New York"
}

JSON Rules You Must Follow

JSON has strict syntax rules. Break any of them and your JSON becomes invalid.

Rule 1: Keys must be strings in double quotes

// ✅ Correct
{ "name": "John" }

// ❌ Wrong — single quotes
{ 'name': 'John' }

// ❌ Wrong — no quotes
{ name: "John" }

Rule 2: Use commas between items, but NOT after the last one

// ✅ Correct
{
  "name": "John",
  "age": 30
}

// ❌ Wrong — trailing comma
{
  "name": "John",
  "age": 30,
}

Rule 3: Strings use double quotes, never single

// ✅ Correct
{ "city": "London" }

// ❌ Wrong
{ "city": 'London' }

Rule 4: No comments allowed

Unlike JavaScript or Python, JSON does not support comments.

// ❌ This is not valid JSON
{
  // this is a comment
  "name": "John"
}

Where is JSON Used?

APIs (Most Common Use)

When you use any web app — checking the weather, loading a social media feed, placing an online order — your browser is communicating with a server through an API. That data is almost always transferred as JSON.

Example response from a weather API:

{
  "location": "New York",
  "temperature": 72,
  "unit": "fahrenheit",
  "conditions": "partly cloudy",
  "humidity": 65
}

Configuration Files

Many developer tools use JSON for configuration:

  • package.json — Node.js project config
  • tsconfig.json — TypeScript settings
  • .prettierrc — code formatting rules
  • manifest.json — web app manifest

Databases

NoSQL databases like MongoDB store data in a JSON-like format called BSON. Even SQL databases now have JSON column types.

Local Storage

Web browsers use JSON to store data locally in localStorage and sessionStorage.


How to Format JSON

Raw JSON from an API often looks like this — one long line:

{"name":"John","age":30,"email":"john@example.com","tags":["developer","blogger"]}

That's valid JSON, but nearly impossible to read. Use our JSON Formatter tool to instantly beautify it:

{
  "name": "John",
  "age": 30,
  "email": "john@example.com",
  "tags": [
    "developer",
    "blogger"
  ]
}

Just paste your JSON in and click Format / Beautify. The tool also:

  • Validates your JSON and shows errors with exact messages
  • Lets you minify JSON back to a single line for production use
  • Works entirely in your browser — your data stays private

Common JSON Errors and How to Fix Them

"Unexpected token"

Usually means a missing comma, bracket, or brace.

// Error: missing comma after "name"
{
  "name": "John"
  "age": 30
}

// Fix:
{
  "name": "John",
  "age": 30
}

"Expected property name"

Usually means you used single quotes instead of double quotes for a key.

// Error: single-quoted key
{ 'name': "John" }

// Fix:
{ "name": "John" }

"Unexpected end of JSON input"

Usually means an unclosed bracket or brace.

// Error: missing closing }
{
  "name": "John",
  "age": 30

// Fix:
{
  "name": "John",
  "age": 30
}

"Trailing comma"

Some parsers reject a comma after the last item.

// Error:
{
  "name": "John",
  "age": 30,
}

// Fix:
{
  "name": "John",
  "age": 30
}

JSON vs XML vs CSV

Before JSON, XML was the standard for data exchange. Here's the same data in all three formats:

JSON:

{ "name": "Alice", "age": 28, "city": "Paris" }

XML:

<user>
  <name>Alice</name>
  <age>28</age>
  <city>Paris</city>
</user>

CSV:

name,age,city
Alice,28,Paris

JSON won because it's more compact than XML, more flexible than CSV, and natively understood by JavaScript (the language of the web).


Frequently Asked Questions

Is JSON a programming language?

No. JSON is a data format, not a programming language. It has no logic, no functions, and no variables.

Can JSON have arrays at the top level?

Yes. JSON doesn't have to start with {}. It can start with []:

["apple", "banana", "cherry"]

What's the difference between JSON and a JavaScript object?

They look very similar, but a JavaScript object allows unquoted keys, single quotes, and functions. JSON is stricter — keys must be double-quoted strings, and no functions are allowed.

How do I convert JSON to CSV?

Use our JSON to CSV converter tool (coming soon), or use a tool like convertcsv.com.


Conclusion

JSON is the backbone of modern web development. Once you understand its six data types and handful of syntax rules, you can read and write it confidently.

Whenever you need to format, validate, or minify JSON, use our free JSON Formatter — it's instant, free, and completely private.

HH

Hafiz Hanif

Full-Stack & Agentic AI Developer · Dubai

10+ years shipping products across the UAE, USA, Saudi Arabia, and Pakistan. I build ToolsMadeEasy on the side because useful tools should be free. More about me →

Try Our Free Tools

Explore our complete collection of free online tools — no signup required.

Browse All Tools