JSON is the language of the modern web — every API response, every config file, every database export uses it. Yet staring at a wall of minified JSON is something developers, testers, and even non-technical product managers deal with every day. This guide explains what JSON is, how to read and fix it, the most common errors and how to resolve them, and when to use a formatter vs a validator.
JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and transmitting structured data. It was created by Douglas Crockford in the early 2000s and standardised as ECMA-404. Despite the name, JSON is completely language-independent — it works identically in Python, Java, Go, Dart, Ruby, PHP, and every other major language.
JSON became dominant because it solves a real problem: how do two completely different systems — say, a React frontend and a Django backend — exchange data? They agree on a common text format both can read. JSON is that format. Simpler than XML, lighter than binary formats, and natively understood by JavaScript (which runs in every browser).
JSON has a simple, rigid structure. Once you understand the six data types and two containers, you can read any JSON document.
{
"user": {
"id": 1042,
"name": "Priya Sharma",
"email": "priya@example.com",
"isVerified": true,
"balance": 4250.75,
"tags": ["premium", "kyc-done"],
"address": null
}
}
| JSON Data Type | Example | Notes |
|---|---|---|
| String | "Priya Sharma" | Must use double quotes — never single quotes |
| Number | 1042 or 4250.75 | No quotes. Integers or decimals. No NaN or Infinity. |
| Boolean | true / false | Lowercase only — not True or False |
| Null | null | Lowercase only — represents absence of value |
| Object | {"key": "value"} | Key-value pairs inside curly braces. Keys must be strings. |
| Array | ["a", "b", "c"] | Ordered list inside square brackets. Any data types allowed. |
The golden rule of JSON: Every key must be a double-quoted string. Every string value must use double quotes. No trailing commas after the last item. Get these three right and 90% of JSON errors disappear.
The same JSON can be written in two ways — formatted (pretty-printed) or minified. They are functionally identical; the difference is only whitespace.
{"name":"Rahul","age":28,"city":"Bengaluru"}
{
"name": "Rahul",
"age": 28,
"city": "Bengaluru"
}
| Use Case | Use Minified | Use Formatted |
|---|---|---|
| API production responses | ✓ Smaller payload | |
| Debugging API responses | ✓ Human-readable | |
| Config files (package.json, etc.) | ✓ Easy to edit | |
| Storing JSON in database | ✓ Less storage | |
| Code reviews and documentation | ✓ Reviewable | |
| Sharing data between teams | ✓ Readable by all |
These are the errors that break JSON parsers — and show up constantly when copying JSON from logs, Postman, or browser DevTools:
❌ {"name": "Priya", "age": 28,} — the comma after 28 is invalid in JSON (unlike JavaScript). ✅ Remove the final comma: {"name": "Priya", "age": 28}
❌ {'name': 'Priya'} — single quotes are valid JavaScript but NOT valid JSON. ✅ Always use double quotes: {"name": "Priya"}
❌ {name: "Priya"} — JavaScript allows unquoted keys but JSON does not. ✅ All keys must be quoted strings: {"name": "Priya"}
❌ {"name": "Priya" // user name} — JSON does not support any comment syntax. ✅ Remove all comments. Use JSONC (JSON with Comments) format only in specific tools like VS Code settings that explicitly support it.
❌ {"score": NaN, "rank": undefined} — these are JavaScript-specific values with no JSON equivalent. ✅ Replace with null or omit the key entirely from the JSON output.
The most invisible error: A BOM (Byte Order Mark) character at the very start of a JSON file — invisible in most text editors but causes immediate parse failure. If your JSON looks perfectly valid but still throws errors, open it in a hex editor or use a formatter that detects and strips BOM characters.
| Method | How to Use | Best For |
|---|---|---|
| ToolLoom JSON Formatter | Paste JSON → validates instantly, shows line of error | Quick one-off checks, no setup |
| Browser console | JSON.parse(yourString) → throws SyntaxError if invalid | Developers debugging API responses |
| Python | import json; json.loads(s) → raises json.JSONDecodeError | Backend validation in Python scripts |
| jq (command line) | cat file.json | jq . → formats and validates | DevOps, CI/CD pipelines, shell scripts |
| VS Code | Open .json file → errors shown in Problems panel automatically | Editing config files and fixtures |
| Postman | API response tab → auto-formats and highlights JSON errors | API testing and development |
| Feature | JSON | XML |
|---|---|---|
| Readability | More readable | Verbose, tag-heavy |
| File size | Smaller (30–40% lighter) | Larger due to closing tags |
| Native browser support | Natively parsed by JS | Requires DOMParser |
| Comments support | Not supported | Supported |
| Attributes | Not applicable | Supported |
| Schema validation | JSON Schema (less mature) | XSD (very mature) |
| Modern API usage | Dominant (REST APIs) | Legacy (SOAP, enterprise) |
| Indian government APIs | UPI, DigiLocker, GSTN | Some older MCA, IRCTC systems |
India's digital public infrastructure runs on JSON. Understanding the JSON structure of these APIs is essential for Indian developers building fintech, healthtech, or government-integrated apps:
For Indian developers: When debugging UPI or GSTN API errors, paste the raw JSON response into ToolLoom's formatter to instantly see the structure. Government API responses often contain deeply nested JSON — a formatter with collapsible tree view makes the structure immediately visible.
| Practice | Why It Matters | Example |
|---|---|---|
| Use camelCase for JSON keys | Consistent with JavaScript conventions; easier to map to JS object properties | userId not user_id or UserId |
| Always validate API JSON before parsing | Unexpected null fields or missing keys cause runtime crashes in production | Use try/catch around JSON.parse() in JavaScript |
| Use ISO 8601 for dates | JSON has no native date type — ISO strings are unambiguous across timezones | "createdAt": "2026-06-13T10:30:00Z" |
| Avoid deeply nested JSON | More than 3–4 levels of nesting makes APIs hard to consume and document | Flatten structures where possible; use IDs instead of nested objects |
| Include a version field in API JSON | Allows graceful API evolution without breaking existing consumers | "apiVersion": "2.0" at root level |
ToolLoom builds free developer and productivity tools for Indian students, professionals, and creators. Found an error or want a feature added to the JSON Formatter? Email us at contact@toolloom.in