HomeGuides What Is JSON? A Beginner's Guide (With Examples)

What Is JSON? A Beginner's Guide (With Examples)

If you have touched an API, a config file or a modern web app, you have met JSON — often without being told what it is. It is the quiet workhorse that lets programs exchange data in a format both machines and humans can read. Here is what it is and how to use it correctly.

JSON in one sentence

JSON — JavaScript Object Notation — is a lightweight, text-based way to represent structured data as key-value pairs and ordered lists. It came from JavaScript's object syntax but is now language-independent: Python, Java, Go, PHP and virtually everything else can read and write it.

Its one job is data interchange. When an app asks a server for your profile, the answer is almost certainly JSON.

What it looks like

A small example: an object in curly braces holding a name (a string in double quotes), a number, a boolean, an array of strings, and a nested object. Read it top to bottom and the shape is obvious — that readability is exactly why JSON won.

The JSON Formatter here beautifies and validates JSON entirely in your browser, so even sensitive data never leaves your device.

The building blocks

  • Objects { } — unordered collections of key-value pairs; keys are always double-quoted strings.
  • Arrays [ ] — ordered lists of values separated by commas.
  • Strings "..." — text, always in double quotes.
  • Numbers, booleans (true / false), and null — written without quotes.

The rules that trip people up

JSON is strict, and most "invalid JSON" errors come from a few rules: keys and strings must use double quotes, not single; no trailing comma after the last item; every bracket and brace must be balanced; standard JSON allows no comments; and numbers have no leading zeros. When something will not parse, a formatter points to the exact line where the structure breaks.

JSON vs a JavaScript object

A common confusion: JSON is text. A JavaScript object lives in memory; JSON is its written, string form. That is why you "parse" JSON into an object and "stringify" an object into JSON. Compared with its neighbours, JSON is more compact than XML, can nest data that CSV cannot, and is less whitespace-sensitive than YAML.

Frequently asked questions

Is JSON a programming language? No — it is a data format, with no logic, loops or functions.

Why does my JSON say "Unexpected token"? Almost always a trailing comma, a single quote, an unclosed bracket or a stray comment.

Can JSON store dates? Not natively — dates are stored as strings, usually in ISO 8601 form, and parsed by the receiving program.

Related tools

Last updated: August 27, 2026