JSON — short for JavaScript Object Notation — is the lingua franca of modern web APIs, configuration files, and data exchange. If you've ever called a REST API, edited a package.json file, or stored settings in a SaaS app, you've worked with JSON. This guide walks through what JSON is, how it works, and how to avoid its most common pitfalls.

What Is JSON?

JSON is a lightweight, text-based, language-independent data format. It was originally derived from JavaScript object literals but is now supported by virtually every programming language. The official spec is RFC 8259.

Two things make JSON popular: it's human-readable, and it maps cleanly to the data structures most languages already have (objects, arrays, strings, numbers).

JSON Syntax in 5 Minutes

A JSON document is built from just six types of values:

Here's a realistic example:

{
  "name": "QuickTools",
  "version": "1.0",
  "free": true,
  "tools": ["Word Counter", "Password Generator"]
}

The Rules You Must Remember

JSON is strict. These rules trip up beginners daily:

Common JSON Errors and How to Fix Them

Unexpected token

Usually caused by a missing comma, a stray comma at the end, or single quotes instead of double quotes. Run your JSON through our JSON Formatter and the error message will tell you the exact position.

Unexpected end of input

You're missing a closing } or ]. Beautify the JSON to see the structure clearly.

Bad escape sequence

Special characters inside strings need escaping: use \" for quotes, \\ for backslashes, \n for newlines.

JSON vs Other Formats

JSON isn't perfect for every situation. Quick comparison:

Beautify vs Minify

JSON has two common forms:

Our JSON Formatter tool handles both with one click.

Working with JSON Programmatically

In JavaScript:

const obj = JSON.parse(jsonString); // parse to object
const str = JSON.stringify(obj, null, 2); // back to formatted string

Most languages have similar built-in support — Python has json, Go has encoding/json, Ruby has JSON.parse, and so on.

Security Considerations

Never eval() a JSON string. Always use the safe parser provided by your language. If you accept JSON from users, validate the structure and sanitize values before using them in queries or rendering them in HTML.

Conclusion

JSON's simplicity is what makes it so successful. With six value types and a handful of strict rules, you can describe almost any data structure in a way both humans and machines can read. Bookmark our JSON Formatter and you'll never wrestle with a syntax error again.