JSON Formatter

JSON Tutorial: What It Is and How to Read It

📅 April 2026 ⏱ 7 min read ✍️ ToolsBox

JSON is everywhere. APIs return it, config files use it, databases store it. If you have ever copied text from an API and seen something that looked like {"name":"Alice","age":30} and wondered what it means, this guide is for you. We will cover the structure from scratch, walk through every data type, show the most common mistakes, and show you how to read any JSON file in minutes.

What Is JSON?

JSON stands for JavaScript Object Notation. It is a lightweight text format for storing and exchanging structured data. Despite the "JavaScript" in the name, JSON is completely language-independent — it is used in Python, Ruby, Go, PHP, Java, Swift, and virtually every other programming language.

The reason JSON became the dominant data format is simplicity. It is human-readable, compact, and maps naturally to the data structures (objects and arrays) that exist in nearly every language. Before JSON, XML was the standard — and JSON largely replaced it because XML is verbose and harder to read.

The Basic Structure: Key-Value Pairs

A JSON object is a collection of key-value pairs wrapped in curly braces { }. Each key is a string in double quotes, followed by a colon, followed by the value:

{
  "name": "Alice",
  "age": 30,
  "city": "London"
}

Rules to remember:

  • Keys must always be in double quotes (not single quotes).
  • Key-value pairs are separated by commas.
  • The last pair in an object has no trailing comma — this is one of the most common mistakes.

JSON Data Types

JSON supports six data types. Understanding each is essential for reading any JSON document:

TypeExampleNotes
String"hello world"Always double-quoted
Number42 or 3.14No quotes — integer or float
Booleantrue or falseLowercase, no quotes
NullnullRepresents no value
Object{"key": "value"}Nested key-value pairs
Array[1, 2, 3]Ordered list of values

Arrays in JSON

An array is an ordered list of values wrapped in square brackets [ ]. Values are separated by commas. Array items can be any data type — including other objects or arrays:

{
  "fruits": ["apple", "banana", "orange"],
  "scores": [95, 87, 72],
  "active": [true, false, true]
}

To access the second fruit, most languages use zero-based indexing: fruits[1] returns "banana".

Nesting: Objects Inside Objects

JSON objects can contain other objects as values. This is called nesting and is how complex data structures are represented:

{
  "user": {
    "id": 1,
    "name": "Alice",
    "address": {
      "street": "10 Main St",
      "city": "London",
      "postcode": "SW1A 1AA"
    }
  }
}

To access the city, you would traverse: user → address → city. In JavaScript that is data.user.address.city.

Valid vs Invalid JSON

JSON has strict syntax rules. A single mistake renders the entire document invalid and will cause a parse error. The most common mistakes are:

  • Trailing comma{"name": "Alice",} is invalid (comma after the last item).
  • Single quotes{'name': 'Alice'} is invalid. JSON requires double quotes.
  • Unquoted keys{name: "Alice"} is invalid. Keys must be quoted.
  • Comments — JSON does not support comments. // this is a comment will break parsing.
  • Mismatched brackets — every { needs a closing } and every [ needs a ].

How to Format and Validate JSON Online

When you receive a JSON blob from an API, it is often minified — everything on one line with no spaces. That makes it nearly impossible to read. Pasting it into the ToolsBox JSON Formatter instantly reformats it with clean indentation and highlights any syntax errors.

  1. Copy your JSON text.
  2. Paste it into the JSON Formatter.
  3. Click Format — the output is properly indented and colour-coded.
  4. If there is an error, the tool shows the exact position of the problem.
  5. Use Minify to compress it back to a single line when needed.

Format and validate your JSON — free

Beautify, minify or fix syntax errors in seconds. No signup, runs in your browser.
Open JSON Formatter →

Where You Will Encounter JSON

Once you know what JSON looks like, you will spot it everywhere:

  • REST APIs — virtually all web APIs return JSON responses.
  • Config filespackage.json, tsconfig.json, VS Code settings.
  • NoSQL databases — MongoDB stores documents as JSON-like BSON.
  • Authentication tokens — JWT (JSON Web Tokens) use Base64-encoded JSON.
  • Browser storagelocalStorage and sessionStorage often store JSON strings.

Frequently Asked Questions

What does JSON stand for?

JSON stands for JavaScript Object Notation. Despite the name, it is completely language-independent and used across virtually every programming language as a data exchange format.

What is the difference between JSON and XML?

Both are text-based data formats. JSON is more compact, easier to read and natively supported in JavaScript. XML uses verbose opening and closing tags; JSON uses key-value pairs and brackets. JSON has largely replaced XML for web APIs.

What are the most common JSON errors?

Trailing commas after the last item in an object or array, single quotes instead of double quotes around strings, unquoted keys, and missing or mismatched curly or square brackets.

How do I validate JSON online?

Paste your JSON into the ToolsBox JSON Formatter. If it is valid, it formats cleanly. If there is an error, the tool shows the exact position of the problem so you can fix it.

Back to Blog  |  Related tool: Free JSON Formatter