RUNWEBTOOLS
English
Data Formats & Encoding

What Is JSON? A Plain-English Guide (and How to Fix Common Errors)

Updated 2026-07-06

JSON is everywhere in modern software — configuration files, API responses, databases, and settings all rely on it. Yet a single stray comma can break an entire file and leave you staring at a cryptic “Unexpected token” error. This guide explains what JSON is in plain English, how its syntax actually works, and how to diagnose and fix the errors you'll run into most often.

What JSON is

JSON stands for JavaScript Object Notation. It's a lightweight, text-based format for storing and exchanging structured data. Despite the name, it isn't tied to JavaScript — virtually every programming language can read and write it, which is exactly why it became the default language of web APIs.

The whole point of JSON is to be readable by both humans and machines. It represents data as a combination of a few simple building blocks:

  • Objects — collections of key/value pairs wrapped in curly braces { }.
  • Arrays — ordered lists wrapped in square brackets [ ].
  • Values — a string, a number, true, false, null, an object, or an array.

Here's a small but complete example:

{
  "name": "Ada Lovelace",
  "active": true,
  "age": 36,
  "skills": ["math", "logic"],
  "address": {
    "city": "London",
    "postcode": null
  }
}

The rules that trip people up

JSON looks a lot like a JavaScript object, and that similarity is the source of most mistakes — JSON is stricter. Keep these rules in mind and you'll avoid the vast majority of errors:

1. Keys and strings need double quotes

Every key must be a string in double quotes, and every text value must use double quotes too. Single quotes are not valid JSON, even though they're fine in JavaScript.

// Invalid
{ 'name': 'Ada' }

// Valid
{ "name": "Ada" }

2. No trailing commas

You cannot leave a comma after the last item in an object or array. This is the single most common JSON error, because many editors and languages happily allow it elsewhere.

// Invalid — comma after the last value
{ "a": 1, "b": 2, }

// Valid
{ "a": 1, "b": 2 }

3. No comments

Standard JSON has no comment syntax. Lines starting with // or blocks wrapped in /* */ will cause a parse error. If you need comments, formats like JSON5 or YAML allow them — see our YAML formatter if that fits your use case better.

4. Numbers are plain

Numbers are written without quotes and without leading zeros or trailing decimal points. 01, 1., and .5 are all invalid; write 1, 1.0, and 0.5.

Common errors and how to fix them

When a parser rejects your JSON it usually reports a line and column. That location points to where the parser gave up, which is often just after the real mistake. Here are the messages you'll see most and what they actually mean:

  • “Unexpected token } in JSON” — almost always a trailing comma before the closing brace or bracket. Remove the extra comma.
  • “Unexpected string” / “Expected comma”— you're missing a comma between two values, or you used a line break where a comma should be.
  • “Unexpected token ' in JSON” — single quotes. Replace them with double quotes.
  • “Unexpected end of JSON input” — a bracket or brace was never closed. Count your { and }; every opener needs a matching closer.
  • “Unexpected token o in JSON” — a classic sign you tried to parse something that was already an object, not a JSON string. Only call a parser on text.

The fastest way to pin down the exact spot is to run the text through a formatter that validates as it goes. Our JSON formatter and validator highlights the precise line and column of the first error and, once the JSON is valid, pretty-prints it so structural problems (a misplaced bracket, a value nested one level too deep) become obvious at a glance. Everything runs in your browser, so you can safely check private or sensitive data.

Format vs. minify

Two operations come up constantly when working with JSON. Formatting(also called beautifying or pretty-printing) adds indentation and line breaks to make a dense blob readable — ideal while you're debugging. Minifying strips every unnecessary space and newline to produce the smallest possible output — ideal for sending over the network or embedding in code, where size matters. The data is identical either way; only the whitespace changes.

Quick checklist

Before you hand JSON to a program, verify:

  • All keys and string values use double quotes.
  • There are no trailing commas.
  • There are no comments.
  • Every bracket and brace is balanced.
  • It passes a validator with no errors.

Get those five right and JSON becomes what it was designed to be: a boring, predictable format that just works. When something does slip through, paste it into the JSON formatter and let it point you straight to the problem.

More in Data Formats & Encoding

See all Data Formats & Encoding guides →

Tools mentioned in this guide