Your files stay with you.
Guide · 4 min read

What Is JSON? A Plain-English Guide with Examples

Learn what JSON is, how its syntax works, the six data types it supports and the mistakes that cause most parse errors, with short examples you can try in your browser.

Updated

If you have ever looked at the settings file of an app, the response from a web API or an export from a modern tool, you have probably seen JSON. It looks like a jumble of braces and quotes at first, but the rules behind it are short and strict, and once you know them you can read almost any JSON file at a glance.

What JSON stands for

JSON means JavaScript Object Notation. It was taken from the way JavaScript writes objects, but today it is independent of any language. Python, PHP, Java, Go, Swift and almost every other language can read and write it, which is why it became the default way for programs to exchange data over the web.

JSON is plain text. You can open it in any editor, send it in an email or paste it into a chat. There is no hidden binary part, and that simplicity is a big reason it replaced XML in most web APIs.

A first example

Here is a small JSON document describing a book:

{
  "title": "The Pragmatic Reader",
  "pages": 312,
  "inStock": true,
  "tags": ["guide", "reference"],
  "author": { "name": "Sam Lee", "country": "CA" },
  "subtitle": null
}

The whole thing is an object, wrapped in curly braces. Inside it are key–value pairs. Each key is a string in double quotes, followed by a colon and a value. Pairs are separated by commas.

The six data types

Every value in JSON is one of exactly six types:

  • String: text in double quotes, such as "Sam Lee". Special characters are escaped with a backslash, so a quote inside a string is written \" and a new line is \n.
  • Number: such as 312, -4.5 or 1.2e6. There is no separate integer type, and numbers are never quoted.
  • Boolean: true or false, in lower case and without quotes.
  • Null: null, meaning “no value”.
  • Array: an ordered list in square brackets, such as ["guide", "reference"]. Items can be any type, including other arrays and objects.
  • Object: a set of key–value pairs in curly braces. Objects can be nested as deeply as you need.

Notice what is missing: there are no dates, no comments and no functions. Dates are usually stored as strings in ISO format ("2026-10-30T14:00:00Z") or as Unix timestamps.

The mistakes behind most parse errors

JSON parsers are strict. A file that is “almost” JSON will be rejected, and the error message often points to the line after the real problem. These are the usual causes:

  • Single quotes. {'name': 'Sam'} is valid in JavaScript but not in JSON. Keys and strings must use double quotes.
  • Trailing commas. A comma after the last item, as in [1, 2, 3,], is not allowed.
  • Unquoted keys. {name: "Sam"} fails; it must be {"name": "Sam"}.
  • Comments. // and /* */ are not part of JSON. Some tools accept them (a format often called JSONC), but standard parsers do not.
  • Smart quotes. Copying JSON from a word processor or chat app can turn straight quotes into curly ones, which a parser does not recognise.
  • Special values. NaN, Infinity and undefined are not valid JSON values.

The quickest way to find the problem is to paste the text into the JSON Formatter & Validator. It points to the exact line and column of the first error, and once the JSON is valid it indents it so the structure is easy to follow.

Pretty-printed versus minified

The same data can be written with indentation and line breaks (pretty-printed) or with every unnecessary space removed (minified). Both are identical to a program. Pretty-printed JSON is easier for people to read and review; minified JSON is smaller, which matters when it travels over a network millions of times a day. Most APIs send minified JSON, so formatting it is usually the first step when you want to understand a response.

JSON and spreadsheets

JSON is great for nested data, but many people need the same information in a spreadsheet. If your JSON is an array of similar objects, such as a list of orders or contacts, each object can become a row and each key a column. The JSON to CSV does this, and flattens nested objects into column names like author.name. Going the other way, the CSV to JSON turns a spreadsheet export into an array of objects that a program or API can use.

Keep in mind that the conversion is not always perfect. A spreadsheet is a flat grid, so deeply nested arrays have to be joined into a single cell or split across columns.

Is it safe to paste JSON into an online tool?

JSON often contains private data: customer records, configuration files with API keys, or tokens. Many online formatters send what you paste to their server. The tools on this site run entirely in your browser, so the text never leaves your device. You can check this yourself by disconnecting from the internet after the page loads; the formatter keeps working. Our guide on whether online converters are safe explains what to look for on any site.

Quick reference

  • Objects use { }, arrays use [ ].
  • Keys and strings always use double quotes.
  • Values are strings, numbers, true, false, null, arrays or objects.
  • No trailing commas, no comments.
  • The file encoding should be UTF-8.

Tools in this guide

More guides