JSON is the format behind almost every web API, many configuration files and most NoSQL databases. It is simple to read when it is laid out with indentation, and almost impossible to read when it arrives as one 40,000-character line. This guide explains what “formatting” and “validating” JSON actually mean, how to read a structure quickly, and when to minify or sort it instead.
What valid JSON looks like
A JSON document is one value: an object ({ } with "key": value pairs), an array ([ ] with values separated by commas), a string in double quotes, a number, true, false or null. Values can nest to any depth.
{
"id": 1042,
"name": "Asha Rao",
"active": true,
"tags": ["admin", "beta"],
"address": { "city": "Pune", "pin": "411001" },
"manager": null
}
The rules are strict, and stricter than JavaScript: keys must be in double quotes, strings must use double quotes, there are no comments, no trailing commas, no undefined, no NaN and no leading zeros on numbers. The specification is RFC 8259.
Formatting (pretty-printing)
A formatter parses the JSON and writes it back with line breaks and indentation, one key per line. Nothing about the data changes; only whitespace is added. The JSON Formatter offers three conventions:
- 2 spaces — the default in JavaScript, TypeScript and most web projects.
- 4 spaces — common in Python (
json.dumps(data, indent=4)) and Java projects. - Tabs — lets each reader choose their own indent width.
Pick whatever your project already uses; consistency matters more than the choice. A good formatter is also lossless: it does not round large numbers. JavaScript stores numbers as 64-bit floating point, so an ID such as 9007199254740993 silently becomes 9007199254740992 if a tool parses and re-serialises it naively. SnipFerry keeps the original digits.
Reading big JSON quickly
Formatted JSON with thousands of lines is still hard to navigate. A tree view helps: the JSON Viewer collapses objects and arrays so you can open only the branch you care about, search for a key or value, and copy the exact path of any field — for example $.orders[3].items[0].sku — to use in code, a test or a JSONPath query.
Three habits make unfamiliar JSON easier to understand:
- Look at the top level first: is it an object with metadata (
status,page,data) or a bare array of records? - Find the array of records and open just its first item to see the shape of one record.
- Note which fields are sometimes missing or
null; those are the ones that break code.
Validating
Validation answers one question: will a strict JSON parser accept this text? A good validator does more than say “invalid”: it reports the line and column of the first error and explains it in plain words. The JSON Validator also warns about two problems that are technically valid but dangerous:
- Duplicate keys in the same object. Most parsers silently keep the last one, so data disappears without an error.
- Numbers too large to store exactly in JavaScript, which will be rounded by browsers and Node.js.
Syntax validation is different from schema validation, which checks that the data has the expected fields and types (“age must be an integer”). For that, generate a JSON Schema from a sample and validate against it in your code.
Minifying
Minifying removes all unnecessary whitespace. A typical pretty-printed API response shrinks by 20–40%. That matters for data embedded in HTML pages, stored in databases or sent at high volume, though for HTTP responses gzip or Brotli compression already removes most of the difference. Use the JSON Minifier when you need compact output, and the formatter when a person needs to read it.
Sorting keys
JSON objects are unordered by definition, but people and version-control systems care about order. Two config files with the same content in a different order produce a noisy diff. Sorting keys alphabetically, recursively, gives every file a canonical order, which makes reviews and comparisons much cleaner. Arrays are left in their original order because array order is meaningful.
Privacy: why a browser-based formatter matters
JSON you paste into an online tool often contains access tokens, customer records or internal URLs. Many formatter websites send that text to their server. SnipFerry’s JSON tools run entirely in your browser, so production payloads never leave your machine — but whichever tool you use, it is good practice to remove secrets before sharing JSON with anyone.
Quick reference
| Task | Tool |
|---|---|
| Make JSON readable | JSON Formatter |
| Find why JSON is rejected | JSON Validator |
| Explore a large structure | JSON Viewer |
| Shrink it | JSON Minifier |
| Stable order for diffs | Sort Keys |
| Fix broken JSON | JSON Repair — see common JSON errors |