InstaCalcs
Tools5 min read

What Is JSON? A Beginner's Guide to JavaScript Object Notation

JSON is everywhere. Every time you check the weather on your phone, scroll through social media, or add something to your online shopping cart, JSON is almost certainly involved behind the scenes. It's the format that web applications use to send data back and forth: server to browser, app to API, one system to another.

If you're starting out in programming or just curious about how the web works, understanding JSON is genuinely useful. It's one of the simplest and most universal formats in computing, and you can learn the entire specification in about 10 minutes.

JSON in Plain English

JSON stands for JavaScript Object Notation. Don't let the name fool you. While it was inspired by JavaScript, it's used by virtually every programming language today. Python, Java, Go, Ruby, PHP, C# all read and write JSON natively.

Think of JSON as a way to write down structured information as text. Imagine you need to describe a person using only a text file. You could write something unstructured like "John Smith is 34 years old and lives in Austin, Texas." But a computer can't reliably pull data out of a sentence like that. JSON gives you a standard structure:

{"name": "John Smith", "age": 34, "city": "Austin", "state": "Texas"}

That's valid JSON. It's a collection of key-value pairs, labels paired with their values. Any program in any language can parse this and immediately know that the "age" field is 34 and the "city" is Austin. No guessing, no ambiguity.

The Syntax Rules

JSON's syntax is strict but minimal. There are really only a handful of rules, and once you know them, you know all of JSON.

Objects are wrapped in curly braces {} and contain key-value pairs separated by commas. Every key must be a string in double quotes. A colon separates the key from the value. So {"color": "blue", "count": 5} is an object with two properties.

Arrays are wrapped in square brackets [] and contain ordered lists of values separated by commas. Like [1, 2, 3] or ["apple", "banana", "cherry"]. Arrays can hold any mix of data types, including other arrays and objects.

Strings must use double quotes. Not single quotes. That's the most common syntax mistake beginners make. "hello" is valid. 'hello' is not. Inside a string, you escape special characters with a backslash: \" for a literal quote, \n for a newline, \\ for a backslash.

No trailing commas. In JavaScript, you can put a comma after the last item in a list. In JSON, you can't. {"a": 1, "b": 2,} — that trailing comma after the 2 makes it invalid. This trips people up constantly.

No comments. JSON doesn't support comments of any kind. No // line comments, no /* block comments */. This is probably its most controversial limitation. If you need to annotate your JSON, you'll have to use a separate documentation file or a format like JSONC (JSON with Comments), which some tools support.

Data Types JSON Supports

JSON supports exactly six data types. That's part of its beauty — there's very little to learn.

Strings: Text in double quotes. "Hello world"

Numbers: Integers or decimals, positive or negative. 42, -17, 3.14159. No quotes around numbers — that would make them strings. JSON doesn't distinguish between integers and floating-point numbers; they're all just "numbers."

Booleans: true or false (lowercase, no quotes).

Null: null represents an empty or missing value (lowercase, no quotes).

Objects: Collections of key-value pairs in curly braces.

Arrays: Ordered lists of values in square brackets.

Objects and arrays can be nested as deeply as you need. An object can contain arrays of objects, which contain other objects, and so on. A typical API response might be three or four levels deep. Real-world JSON from complex systems can go much deeper than that.

Common Mistakes That Break JSON

JSON parsers are unforgiving. One misplaced character and the whole thing fails. Here are the errors that catch people most often:

Single quotes instead of double quotes. This is the #1 mistake, especially for Python developers. Python uses single quotes freely, but JSON requires double quotes for all strings and keys. {'name': 'John'} is valid Python but invalid JSON.

Trailing commas. Most programming languages allow a comma after the last item in a list or object. JSON doesn't. Remove that comma or your parser will throw an error. This is so common that there's a popular joke: "JSON is the only language where a trailing comma is a federal crime."

Unquoted keys. In JavaScript, you can write {name: "John"} without quoting the key. In JSON, every key must be quoted: {"name": "John"}. No exceptions.

Using undefined. JavaScript has undefined as a value, but JSON doesn't. If a field has no value, use null.

Special number values. JSON doesn't support NaN, Infinity, or -Infinity. If you need to represent these, you'll have to use a string or null and handle the conversion in your code.

When your JSON won't parse and you can't spot the error, paste it into our JSON Formatter. It'll pinpoint exactly where the syntax breaks and format everything neatly so you can see the structure.

Why JSON Won

Before JSON became dominant, the main data exchange format was XML. If you've seen XML, you know it's verbose. Representing our person example in XML would look something like: <person><name>John Smith</name><age>34</age><city>Austin</city></person>. That's a lot of repeated tag names and angle brackets.

JSON carries the same information in roughly half the characters. It's easier to read, easier to write, and faster to parse. When web APIs exploded in the mid-2000s, developers overwhelmingly chose JSON over XML. By 2013, JSON had become the default format for new APIs, and today over 70% of public APIs use JSON as their primary format.

Douglas Crockford, who formalized the JSON specification in 2001, deliberately kept it minimal. The entire spec fits on a single printed page. There are no optional features, no versioning headaches, no extensions. Every JSON parser in every language reads the same format. That simplicity turned out to be JSON's killer feature. It just works, everywhere, all the time.

Where You'll Find JSON

Web APIs. When your weather app fetches the forecast, the server sends back JSON containing temperatures, conditions, wind speed, and so on. Twitter's API, GitHub's API, Stripe's payment API all return JSON. If a service has an API, it almost certainly speaks JSON.

Configuration files. The package.json file in JavaScript projects, tsconfig.json for TypeScript, .prettierrc for code formatting. Tons of tools store their settings in JSON files. VS Code's settings are JSON. Chrome extension manifests are JSON.

Databases. MongoDB stores all its documents as a format called BSON (Binary JSON). PostgreSQL has native JSON and JSONB column types. Many modern databases let you query and index fields inside JSON documents directly.

Local storage. When a web app saves data in your browser's localStorage, it usually serializes it as a JSON string. Same with session storage and many caching mechanisms.

Data exchange between services. In microservice architectures, services communicate by sending JSON messages over HTTP or message queues. A single request on a large platform might trigger dozens of services exchanging JSON payloads before you see a result.

Working with JSON in Practice

Every mainstream programming language has built-in JSON support. In JavaScript, JSON.parse() converts a JSON string into an object, and JSON.stringify() does the reverse. Python uses json.loads() and json.dumps(). The function names differ but the concept is identical: string in, data structure out (and vice versa).

When working with API responses, you'll often get back a giant block of minified JSON — no whitespace, no line breaks, everything on one line. That's efficient for transmission but awful for humans to read. A JSON Formatter adds proper indentation and line breaks so you can actually see the structure.

If you're debugging an API and the response contains Base64-encoded data (common in JWTs and some binary payloads), you'll want to decode that separately to see what's inside.

JSON's strength is its simplicity and universal support. You can go from knowing nothing about it to reading and writing it confidently in a single afternoon. The format won't surprise you with hidden complexity; what you see in this article is genuinely all there is to it. Try pasting some JSON into our JSON Formatter and start exploring.

Ready to run your own numbers?

Try our free calculator and get instant results.

Try our JSON Formatter

InstaCalcs Team

Free calculators and tools for everyday math.