What is JSON?
JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging data. It is the language most web APIs speak: when an app loads your profile, a weather widget fetches the forecast or a payment gateway confirms a transaction, the data usually travels as JSON. It is easy for programs to parse, and with proper formatting it is easy for people to read too.
The problem is that JSON from APIs and log files often arrives as one long line. This formatter turns it into a neatly indented structure, validates it, and can minify it back down when you need the smallest possible payload.
How to Use the JSON Formatter
- Paste your JSON into the input box, or click Load Sample to try it out.
- Choose the indentation — 2, 3 or 4 spaces.
- Click Format / Beautify for readable output, or Minify / Compress for a single compact line.
- If the JSON is invalid, an error message explains what went wrong so you can fix it.
- Copy the result back into your code, API client or documentation.
Before and After
Minified JSON as returned by an API:
{"user":{"id":101,"name":"Asha Verma","city":"Jaipur","skills":["PHP","Laravel"],"active":true}}
The same data formatted with 2-space indentation:
{
"user": {
"id": 101,
"name": "Asha Verma",
"city": "Jaipur",
"skills": [
"PHP",
"Laravel"
],
"active": true
}
}
JSON Syntax Rules
- Data is written as key–value pairs:
"name": "Asha". - Keys must be strings in double quotes.
- Objects use curly braces
{ }; arrays use square brackets[ ]. - Items are separated by commas, with no comma after the last item.
- Allowed value types: string, number, object, array,
true,falseandnull.
Common JSON Errors and Fixes
| Mistake | Invalid | Valid |
|---|---|---|
| Trailing comma | [1, 2, 3,] | [1, 2, 3] |
| Single quotes | {'a': 1} | {"a": 1} |
| Unquoted key | {a: 1} | {"a": 1} |
| Comment | {"a": 1 // id} | {"a": 1} |
| Undefined value | {"a": undefined} | {"a": null} |
When to Minify
Whitespace makes JSON readable but adds bytes. For large API responses or JSON stored in a database or URL, minifying can noticeably reduce size. Most servers also compress responses with gzip, so the main benefit of minifying is cleaner storage and smaller payloads in places that aren’t compressed.
Who Uses a JSON Formatter?
- Backend and frontend developers debugging API requests and responses.
- QA testers checking that responses contain the expected fields.
- Data analysts inspecting exported data before loading it elsewhere.
- Students learning how structured data and APIs work.
Related Tools
- JSON to CSV — open JSON data in Excel or Google Sheets.
- JSON to XML — convert for systems that expect XML.
- CSV to JSON — turn a spreadsheet into JSON.
- XML Formatter — the same idea for XML.