JSON (JavaScript Object Notation) is the dominant data interchange format on the modern web. REST APIs, serverless functions, NoSQL databases, configuration files, webhooks, and build tooling all use JSON. Despite its apparent simplicity, JSON has strict syntax rules — and a single misplaced character causes the entire payload to fail parsing. A JSON formatter is one of the most-used tools in a developer's daily workflow.
JSON Syntax: The 6 Rules That Matter
- Keys must be strings in double quotes — {name: "value"} is invalid; {"name": "value"} is correct
- No trailing commas — {"a":1,"b":2,} is invalid; most parsers reject it
- Strings must use double quotes — single quotes are not valid in JSON
- No comments — // and /* */ are not valid in JSON (use JSONC for config files that support comments)
- Numbers cannot have leading zeros — 007 is invalid; 7 is correct
- The root element can be any JSON value, not just an object or array
Formatted vs Minified JSON: When to Use Each
Formatted (pretty-printed) JSON adds indentation and line breaks for human readability. Use it for debugging, documentation, configuration files, and any situation where a human will read the JSON. Minified JSON removes all whitespace to minimize file size. Use it for API responses, network payloads, and any situation where bandwidth or file size matters. A 10 KB config file formatted with 4-space indentation becomes 6 KB minified — a 40% size reduction from whitespace alone.
Common JSON Errors and How to Fix Them
The most common JSON errors developers encounter: (1) Trailing comma after the last element in an array or object — a habit carried from JavaScript where trailing commas are valid. (2) Single-quoted strings — valid in JavaScript, not in JSON. (3) Undefined or NaN values — valid JavaScript primitives, not valid JSON values. (4) Unescaped special characters in strings — newlines must be \n, tabs must be \t, double quotes must be \". (5) Missing commas between key-value pairs.
Debugging API Responses
The most common use case for a JSON formatter is debugging API responses. When a fetch request returns a large, minified JSON payload, pasting it into a formatter instantly makes the structure readable. You can see nested objects, identify unexpected null values, and trace the data path to the field your code is trying to access. This is significantly faster than trying to read {"user":{"id":1,"profile":{"name":"John","age":30}}} in its minified form.
Privacy Note: Why Client-Side Formatting Matters
Many developers work with sensitive data: user records from a production database, payment transaction payloads, internal API responses with authentication tokens, or medical data. Pasting this into an online JSON formatter that sends data to a server is a security and compliance risk. Our JSON formatter runs entirely in your browser using JavaScript — no network request is made, no data is sent or stored anywhere. You can safely format sensitive payloads.