Skip to content
jsonforge.app
Back to blog
Guide8 min read

What is JSON? A Complete Beginner's Guide

JSON (JavaScript Object Notation) is the lingua franca of the modern web — the format nearly every API, configuration file, and NoSQL database speaks. This guide walks through the syntax, the six data types, and how JSON is actually used.

What is JSON?

JSON is a text-based format for representing structured data. It was derived from JavaScript's object-literal syntax, but it's language-agnostic: nearly every programming language can read and produce JSON.

It was introduced by Douglas Crockford in the early 2000s as a simpler alternative to XML. Today it's an international standard (ECMA-404 / RFC 8259) and the default payload format for REST APIs, GraphQL, and most web services.

JSON syntax basics

JSON has two structures: objects (key/value maps wrapped in curly braces) and arrays (ordered lists wrapped in square brackets). Keys must be double-quoted strings; values can be any of the six data types.

A typical JSON object — keys are double-quoted strings.
{
  "name": "Alice",
  "age": 30,
  "active": true,
  "roles": ["admin", "editor"],
  "address": {
    "city": "San Francisco",
    "zip": "94102"
  },
  "metadata": null
}

Note the rules: keys use double quotes (single quotes are invalid), items are separated by commas, and there's no trailing comma after the last item.

The six data types

JSON supports exactly six data types. Understanding them is the foundation of working with any JSON.

string — text in double quotes, e.g. "hello". number — integers or decimals, e.g. 42 or 3.14. boolean — true or false (unquoted). null — an explicit empty value. object — a { } map of key/value pairs. array — a [ ] ordered list.

That's it. JSON has no dates, no functions, no undefined — those have to be encoded as strings or omitted. This minimalism is what makes JSON so universally interoperable.

Where JSON is used

APIs: nearly every REST and GraphQL endpoint exchanges JSON. Configuration: package.json, tsconfig.json, and countless tool configs are JSON. Databases: MongoDB, CouchDB, and PostgreSQL's JSONB store documents as JSON. Data exchange: the wire format between server and browser in modern web apps.

FAQ

Is JSON the same as a JavaScript object?
No. A JavaScript object literal can contain functions, comments, single-quoted strings, and trailing commas. JSON is stricter: double-quoted keys, no functions, no comments. Every valid JSON document is a valid JavaScript expression, but not vice versa.
Can JSON contain comments?
Standard JSON cannot. Some tools (like VS Code's JSONC) allow comments as an extension, but a strict parser like JSON.parse() will reject them. If you need comments, consider JSON5, YAML, or JSONC.
What's the difference between JSON and XML?
JSON is lighter (no closing tags), maps directly to native data structures, and is faster to parse. XML is more verbose but supports attributes, namespaces, and schemas natively. JSON won for APIs; XML survives in document-heavy domains.

Related articles