An API response comes back as one unbroken 4,000-character line, and somewhere in there is the one field that's null when it shouldn't be. Scrolling through it manually is how developers lose twenty minutes to what should be a two-second fix — which is the entire reason a formatter belongs in the toolbar, not just the interview prep notes.
What Is JSON and Why It Matters
JSON (JavaScript Object Notation) is a lightweight text format for structured data — objects (key-value pairs) and arrays (ordered lists). It's language-independent, human-readable, and natively supported in virtually every programming language. Today JSON powers REST API responses, configuration files, document databases (MongoDB, DynamoDB), web application state, and inter-service communication across microservices architectures.
Pretty Print vs Minified JSON
Pretty-printed JSON uses indentation and line breaks for human readability — ideal for development, debugging, and code reviews. Minified JSON strips all unnecessary whitespace for a smaller file size (often a 20-30% reduction) in production data transfer. The formatter above converts instantly between both. Most REST APIs return minified JSON by default — use the formatter to actually inspect what came back.
| Format | Use Case | Example Size |
|---|---|---|
| Pretty-printed | Development, debugging, docs | ~1.4KB |
| Minified | Production API responses | ~1.0KB |
Common JSON Validation Errors
The formatter flags these recurring errors: single quotes instead of double quotes (JSON requires double quotes — 'key' is invalid, "key" is valid), trailing commas ({"a":1,} is invalid), comments (JSON has no comment syntax at all — // and /* */ are both invalid), unquoted keys ({key: "value"} is invalid — it must be {"key": "value"}), and undefined values (undefined isn't valid JSON — use null instead).
💡 The missing comment syntax isn't an oversight — Douglas Crockford, who formalized JSON, has said publicly he left comments out on purpose to keep parsers simple and prevent people from smuggling parsing directives into data files. It's inconvenient for config files, which is exactly why looser supersets like JSON5 and JSONC (used in VS Code's own settings files) exist — they add comments and trailing commas back in, but they're not standard JSON, and a strict JSON.parse() will reject them.
Working with API Responses
A solid workflow for debugging API responses: copy the raw response from your browser's Network tab or API client, paste it into the formatter, pretty-print to see the actual structure, then validate to catch any malformed data coming from the API itself. Common gotchas in real API JSON: escaped unicode characters (\u0041), date strings in ISO 8601 format, deeply nested objects that need several levels of unpacking, and large integer values that exceed JavaScript's safe integer limit and silently lose precision.
Developer Tips for JSON Work
- Browser DevTools: the Network tab automatically pretty-prints JSON responses — click any request to see the formatted response
- jq command line tool: a powerful JSON processor for filtering and transforming JSON in terminal workflows
- VS Code: built-in JSON formatting (Alt+Shift+F) and schema validation for structured JSON files
- Postman: a strong API client for testing JSON APIs with automatic response formatting
- JSON Schema: defines and validates the expected structure of JSON documents programmatically
Quick Checklist
- Validate JSON before parsing in production code — always wrap JSON.parse() in try-catch
- Use double quotes for all strings and keys — single quotes are not valid JSON
- Remove trailing commas from objects and arrays — they cause parse errors
- Check for undefined values — use null instead (undefined is not valid JSON)
- Minify JSON for production API responses to reduce payload size
- Use browser DevTools Network tab to inspect and format API responses in-place
For informational purposes only. Not financial, tax, or legal advice. Consult a qualified professional before making major decisions.