Blog

What Is JSON? A Beginner's Guide With Real Examples

10 min read
JSON explained with examples showing objects, arrays and strings

What Is JSON? A Beginner's Guide With Real Examples

If you have ever opened a settings file, copied an error from a developer console, or wondered what the strange-looking text behind a website actually is, you have probably met JSON already. What is JSON? JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and exchanging structured data. It looks a little like a list written in code, but it is deliberately designed to be readable by humans and easy for machines to parse — which is why nearly every website, app, and API on the modern web uses it.

The good news: you do not need to be a programmer to read JSON. Once you know its handful of building blocks, you can read almost any JSON file at a glance — and when a file arrives as one unreadable wall of text, the free JSON Formatter on AllNewTools turns it into a clean, indented structure in one click, entirely in your browser.

JSON in One Sentence

JSON is a way of writing data as text, using key–value pairs inside curly braces { } for objects and ordered lists inside square brackets [ ] for arrays. That is the whole idea. Everything else is detail.

Here is a small, real example — a user profile exactly like the ones apps send back and forth thousands of times a day:

{
  "name": "Ayesha Rahman",
  "age": 29,
  "subscribed": true,
  "city": "Dhaka",
  "interests": ["photography", "cycling", "baking"],
  "address": {
    "street": "12 Green Avenue",
    "postcode": "1212"
  }
}

Read it out loud and it almost explains itself: a person named Ayesha Rahman, aged 29, subscribed, living in Dhaka, with three interests and an address. That readability is the point. JSON was designed so that a human can scan it and a program can parse it without ambiguity.

The Six Building Blocks of JSON

Every JSON document is built from just six kinds of values:

  1. Objects — collections of key–value pairs in curly braces. Keys are always strings in double quotes, followed by a colon, then a value. Example: {"name": "Ayesha"}.
  2. Arrays — ordered lists in square brackets. Items are separated by commas and can be any JSON value, including other arrays and objects. Example: ["red", "blue", "green"].
  3. Strings — text in double quotes. Single quotes are not allowed in JSON, and neither are unquoted words.
  4. Numbers — plain numbers, integers or decimals, with no quotes: 29, 19.99, -4.
  5. Booleans — exactly true or false, lowercase, no quotes.
  6. Null — the value null, meaning "intentionally empty" — different from zero or an empty string.

Objects and arrays can nest inside each other as deeply as needed. That nesting is how JSON represents real-world structures: an order containing a list of items, each item containing its own price and quantity.

A Real-World Example: An Online Order

Here is JSON the way it actually appears in the wild — an order from an online shop:

{
  "order_id": "ORD-88412",
  "customer": "Tanvir Hasan",
  "paid": true,
  "total": 74.50,
  "items": [
    { "product": "Logo redesign", "price": 60.00, "quantity": 1 },
    { "product": "Business card design", "price": 14.50, "quantity": 1 }
  ],
  "delivery_email": null
}

Notice a few things. The order is one object. Inside it, items is an array of two smaller objects. paid is a boolean, total a number, and delivery_email is null — the field exists, but no email was provided. If you can read this example, you can read JSON.

Where You Meet JSON Every Day

You may never write JSON yourself and still run into it constantly:

  • Websites and apps. When a page loads your feed, your messages, or search results without reloading, it usually fetches JSON from the site's server behind the scenes.
  • APIs. An API (Application Programming Interface) is how one program talks to another, and JSON is the language most APIs speak. Weather apps, maps, payment systems, and social platforms all exchange JSON.
  • Configuration files. Many tools store their settings in .json files — editor settings, app preferences, and project configs.
  • Data exports. Downloading your data from a service often gives you a JSON file, because it preserves structure better than a flat spreadsheet.
  • No-code tools and automations. Services that connect apps together pass JSON between steps, even when you never see it.

Understanding JSON, even at this basic level, makes error messages, settings files, and data exports far less intimidating.

JSON vs XML vs YAML: Why JSON Won

Before JSON, the dominant data format was XML, which wraps everything in opening and closing tags like <name>Ayesha</name>. XML still exists, but JSON won for most web work because it is shorter, easier to read, and maps directly onto the data structures programming languages already use. A JSON object looks almost identical to a dictionary or hash map in Python, JavaScript, and dozens of other languages.

YAML is another alternative, popular for configuration files because it uses indentation instead of braces. It is arguably even more readable, but its indentation rules make it easier to break accidentally, and it is less suited to data exchanged between systems. For APIs and web data, JSON remains the default choice.

The Rules That Trip Beginners Up

JSON has very few rules, but it enforces them strictly. A single misplaced character makes the whole document invalid. The mistakes that catch almost everyone:

  • Trailing commas. { "a": 1, } is invalid — no comma after the last item in an object or array. This is the single most common error, because JavaScript allows trailing commas and JSON does not.
  • Single quotes. 'name' is not a string in JSON. Strings and keys must use double quotes.
  • Unquoted keys. { name: "Ayesha" } looks fine, but JSON requires { "name": "Ayesha" }.
  • Comments. JSON has no comments. Text like // note inside a JSON file breaks it. (Some config files use "JSONC" — JSON with comments — but strict JSON does not allow them.)
  • Undefined, NaN, and Infinity. These exist in JavaScript but not in JSON. Use null instead of undefined.
  • Trailing content. A JSON document is one single value. Two objects pasted back to back without an enclosing array is not valid JSON.

The strictness is a feature, not a flaw: it guarantees that any program reading the file interprets it exactly the same way.

How to Read and Fix JSON, Step by Step

Step 1: Paste your JSON into the JSON Formatter

Open the JSON Formatter and paste your JSON into the editor — or load the built-in sample to try it out. The tool runs entirely in your browser, so nothing you paste is uploaded anywhere. That matters when the data is an API key, a customer record, or a private configuration.

Step 2: Format it and read the structure

Click Format. Minified JSON that arrived as one endless line becomes an indented tree you can actually scan. Choose 2 spaces, 4 spaces, or Tab indentation — whichever your team or project uses. If the document is invalid, the tool reports the exact line and column of the first syntax error instead of failing silently, so you can jump straight to the problem instead of hunting through the whole file.

Step 3: Fix the first error, then repeat

JSON validators report the first error they find, and later "errors" are often just knock-on effects of the first one. Fix one issue — a trailing comma, a single quote, a missing closing brace — and validate again. Repeat until the document passes. Working one error at a time is dramatically faster than trying to fix everything at once.

Step 4: Minify before sending, format before reading

When JSON needs to travel — inside an API request, a URL, or a data file — whitespace is wasted weight. Minify strips every unnecessary space and line break, producing the smallest possible version of the same data. When a human needs to read it, format it again. The two operations are reverses of each other, and switching between them is the daily rhythm of working with JSON.

Step 5: Copy or download the result

Copy the formatted or minified output to your clipboard, or download it as a .json file. If you are pasting JSON into another system, double-check that the receiving end accepts the same structure — especially if you converted between formats or edited values by hand.

JSON in the Wild: An API Response

Here is what a real API response looks like — weather data, simplified:

{
  "city": "Chittagong",
  "temperature_c": 31,
  "condition": "Partly cloudy",
  "humidity": 78,
  "forecast": [
    { "day": "Saturday", "high": 32, "low": 27 },
    { "day": "Sunday", "high": 31, "low": 26 }
  ]
}

An app takes this text, reads the values, and displays "31° in Chittagong, partly cloudy" on your screen. The JSON itself is never shown to you — but now you know what is happening underneath.

Common JSON Questions, Answered Honestly

JSON is not a programming language — it is only a data format. It cannot run code, loop, or make decisions. That limitation is deliberate: data that cannot execute code is far safer to exchange between systems.

JSON is also not a database. It is excellent for moving data and storing configuration, but large datasets with complex querying belong in a real database. A JSON file with a million records will be slow to search and painful to update.

And JSON is not the same as JavaScript, even though the name suggests it. JSON is a subset of JavaScript's object syntax, tightened up with strict rules. Valid JSON is (almost always) valid JavaScript, but the reverse is not true — JavaScript allows many things JSON forbids.

A Practical Habit for Beginners

The fastest way to get comfortable with JSON is to format something real. Take a settings file from an app you use, a small data export, or the sample in the formatter, and read it line by line: find the outer object, name its keys, and follow one nested array to its end. After three or four documents, the braces and brackets stop looking like noise and start looking like structure — because that is what they are.

If you work with text data regularly, two companion tools are worth knowing. When JSON contains encoded blobs, the Base64 Encoder & Decoder converts them back to readable text (and back again), safely in UTF-8. And when you want to explore the wider collection, the DevKit hub gathers the formatter alongside regex, hash, and encoding utilities — all free, all in your browser.

FAQ: What Is JSON?

What does JSON stand for? JavaScript Object Notation. Despite the name, it is language-independent — nearly every programming language can read and write it.

Is JSON a programming language? No. JSON only describes data. It has no variables, functions, loops, or logic — just values arranged in objects and arrays.

Why do I see JSON as one long line? Because minified JSON removes all whitespace to save space for transmission. Paste it into a formatter to restore readable indentation — the data is identical either way.

What is the most common JSON error? A trailing comma after the last item in an object or array. JSON forbids it, even though JavaScript allows it.

Can JSON contain comments? No. Strict JSON has no comment syntax. If you need notes in a config file, use JSONC (JSON with comments) where the tool supports it, but never in data sent to an API.

Is my JSON safe in an online formatter? It depends on the tool. The AllNewTools formatter runs entirely in your browser — nothing you paste leaves your device — so it is safe even for sensitive data. With any other formatter, assume pasted content could be stored.

JSON Is Simpler Than It Looks

JSON earned its place as the web's data format for one reason: it is the simplest structure that can describe real data without ambiguity. Objects, arrays, strings, numbers, booleans, and null — six pieces, combined and nested, describe a user profile, an order, a weather forecast, or an entire application state. Learn to read those six pieces and you can read any JSON file you will ever meet.

Your formatted JSON is one click away

Paste that wall of minified text and get back clean, readable JSON — free, in your browser, with no sign-up. Your data is never uploaded, so it stays exactly where it belongs: on your device.

▶ Try JSON Formatter — it's free

← Explore more articles