What Is JSON? How to Format, Validate and Beautify JSON

If you have ever opened an API response, a settings file or an error log and seen text full of curly brackets and quotation marks, you have met JSON. It looks like code, but it is just structured data written so humans and machines can both read it.

What is JSON?

JSON stands for JavaScript Object Notation: a plain-text format for storing and exchanging data, built from objects (named values) and arrays (lists).

Defined in the early 2000s and standardised as RFC 8259 in 2017, it is named after JavaScript — but that is history. Almost every language today reads and writes JSON, which is why it became the default for moving data around the web. Here is an example:

{
  "name": "Priya Sharma",
  "age": 28,
  "isStudent": false,
  "courses": ["Python", "SQL", "Data Visualisation"],
  "address": {
    "city": "Indore",
    "pincode": 452001
  }
}

The rules are few and strict: keys are always double-quoted, and values can only be a string, a number, true or false, null, an object or an array. Know those and you can read any JSON file.

Where JSON shows up

  • APIs. When an app asks a server for data — weather, train times, listings — the answer almost always arrives as JSON.
  • Config files. Many tools store settings in JSON, like editor settings and package.json in a JavaScript project.
  • Data files. Datasets, chat exports and app backups are often JSON — simple to generate, easy to inspect.
  • Web pages. The data filling a page — product lists, result tables — is usually fetched as JSON and rendered in the browser.

JSON won because it is just text: open it in any editor, send it over any connection, read it with your own eyes. XML does the same job with more ceremony; binary formats are faster but unreadable. JSON sits in the middle — where most of the web lives.

Objects, arrays and values

JSON has only six kinds of value:

Value typeExampleNotes
String"hello"Always in double quotes
Number42, 3.14, -7No quotes
Booleantrue, falseLowercase only
NullnullMeans “no value here”
Object{"key": "value"}Named values in braces
Array[1, 2, 3]Ordered list in brackets

An object is key-value pairs inside curly brackets: a string key, a colon, a value. Objects are unordered — {"a": 1, "b": 2} and {"b": 2, "a": 1} mean the same thing.

An array is an ordered list inside square brackets. Items can be any values, including other objects and arrays, so you can nest as deeply as you need — which is also where JSON gets hard to read, and why formatting matters.

One rule trips up beginners: JSON has no dates, comments or “undefined”. Dates are strings like "2026-11-18", comments are not allowed, and a missing value is null — a likely reason if a validator has ever called your JSON invalid.

Why formatting matters

Formatting is optional. This is perfectly valid JSON:

{"name":"Priya Sharma","age":28,"courses":["Python","SQL"]}

A machine reads it happily. A human does not. The moment something goes wrong — a missing bracket, a typo in a key — a single-line wall of text is nearly impossible to debug by eye. Formatting (“beautifying”) spreads the same data over lines with consistent indentation, so the structure becomes visible and a missing bracket is easy to find. It changes readability, not the data.

The opposite is minifying: stripping spaces and line breaks to make the file as small as possible — what servers send over the network, because smaller is faster. Humans work with formatted JSON, machines with minified JSON, and a formatter converts between the two in one click.

Common syntax errors (and how to spot them)

JSON is strict, and five mistakes cause most errors:

1. Trailing commas. JavaScript allows a comma after the last item; JSON does not. In { "a": 1, "b": 2, }, drop the comma after 2.

2. Single quotes. JSON only accepts double quotes: 'name' is not a valid key, 'Priya' not a valid string — a trap for people coming from JavaScript or Python.

3. Unquoted keys. Keys must be quoted too. { name: "Priya" } is valid JavaScript but invalid JSON. It has to be { "name": "Priya" }.

4. Comments. There is no way to write a comment in JSON — no //, no /* */. A config file with comments is probably JSONC or JSON5, relatives with extra features.

5. A missing or extra bracket. In a long nested document, one missing } or ] breaks everything, and the error usually points at the end of the file, not the mistake. Format first, and the broken nesting usually becomes obvious.

A validator gives the line and column where parsing stopped — start there; in a formatted copy the problem is usually a line or two away.

How to format, validate and minify JSON

No installation needed. The whole job takes seconds:

  1. Copy your JSON — from an API response, a log or a config file.
  2. Paste it into the JSON Formatter on SoftTools — it runs entirely in your browser, so your data is never uploaded.
  3. Click Format. Valid JSON comes back beautified; invalid JSON comes back with the error and its line and column.
  4. Fix and re-check. Fix the error, paste again, and repeat until it validates.
  5. Copy the result — or take the minified view for sending or storing.

Two habits help. Validate early: check a small piece before pasting it into a large file — one bad character in 500 lines is far harder to find than in ten. And keep a formatted copy of anything you use regularly. The minified version is for machines; the formatted version is for you, six months from now, trying to remember what a field meant.

JSON vs JavaScript objects

JSON looks like a JavaScript object, but confusing the two causes real bugs:

  • JSON is text; an object is data in memory. JSON is a string you can save or send; an object exists only while a program runs.
  • JSON is stricter: double-quoted keys, no trailing commas, no comments, no functions, no undefined — JavaScript objects allow all of those.
  • Converting is explicit: JSON.parse() turns a JSON string into an object, JSON.stringify() turns it back. If JSON.parse() throws, the string was not valid JSON.

Think of JSON as the letter and the object as the idea in your head after reading it — the letter must follow the format’s rules to be delivered.

When NOT to use JSON

JSON is the default for data exchange, but not right for everything:

  • Documents with comments. If humans edit the file and need notes, YAML or JSONC is friendlier — strict JSON rejects comments.
  • Large data you need to query. A database is built for that — searching a 50 MB JSON file by hand is slow; a database answers in milliseconds.
  • Binary data. Images, audio and video do not belong in JSON directly; Base64-encoding them makes the file roughly a third larger.
  • Numbers where precision matters. JSON has one number type, and large integers or exact decimals can lose precision when read back — financial figures are usually stored as strings.
  • Configuration with logic. JSON cannot express “if this, then that”, defaults or references. For config that needs logic, a real config language or a small script is the honest choice.

None of this makes JSON bad — it has a clear job: structured data that travels between systems. Pick something else when the job needs what JSON was never designed for.

FAQs

1. Is JSON a programming language?
No. JSON is a data format — structured information written as text. It has no variables, no loops, no logic. Many languages can read and write it, which is why it feels like part of programming without being one.

2. What is the difference between formatting and validating JSON?
Formatting rearranges valid JSON so it is easy to read, without changing the data. Validating checks whether the text follows JSON’s rules at all. A formatter validates first — invalid input cannot be formatted, and the error says what is wrong.

3. Why does my JSON say “Unexpected token”?
The parser found something unexpected — usually a trailing comma, a single quote, an unquoted key or a missing bracket. The line and column in the error say where parsing stopped; look there first.

4. Can JSON contain comments?
Not in strict JSON. If you need comments, you want JSONC (used by editors like VS Code) or JSON5, which also allows trailing commas and unquoted keys. A standard validator rejects both.

5. What is minified JSON, and when should I use it?
Minified JSON is the same data with all unnecessary whitespace removed — one long line. Use it when size matters, like sending data over a network; use the formatted version whenever a human needs to read or edit it.

6. How is JSON different from XML?
Both are text formats for structured data. XML is more verbose — opening and closing tags — and supports attributes and comments. JSON is shorter, easier to read, and maps directly onto most languages’ data structures, which is why it replaced XML as the default for APIs.

Conclusion

JSON is a small format with a large job: how data travels between the systems we use every day, from APIs and config files to datasets and backups. A handful of rules — double quotes, no trailing commas, six value types — but they are strict, and most “invalid JSON” errors come down to one.

Learn the rules, format before you read, and let a validator point at the exact line when things break. And when a wall of text needs to become readable, format it in seconds with the free JSON Formatter on SoftTools — your data never leaves your browser.

Rahul

Rahul runs SoftTools from India. He builds free, private online tools that work entirely in your browser, and writes practical guides that explain everyday calculations and web tools in plain language.

← Back to all tools