What Is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format defined by RFC 8259. Created by Douglas Crockford in the early 2000s, it has become the default wire format for REST APIs, configuration files, NoSQL databases, and inter-service messaging. JSON is language-independent but uses conventions familiar to programmers of the C family of languages, which is one reason virtually every language ships with a built-in JSON parser.
A valid JSON document is either an object ({}) or an array ([]) at the top level. Inside, JSON supports six value types: strings (double-quoted), numbers, booleans (true/false), null, objects, and arrays. There are no comments, no trailing commas, and no undefined — this strict simplicity is what makes JSON so reliable for machine parsing.
How to Format JSON with This Tool
- Paste your raw, minified, or unformatted JSON into the input area.
- Choose your preferred indentation style — 2 spaces, 4 spaces, or tabs — in the settings panel.
- Click the Format button or press
Ctrl+Enter. - Review the formatted output with proper indentation, line breaks, and syntax highlighting.
- Copy the result with the Copy button or
Ctrl+Shift+C.
The formatter parses your JSON with JSON.parse(), validates it, and re-serializes it with JSON.stringify() using your chosen indentation. Nested objects and arrays are indented consistently, and special characters are properly escaped. If the input is invalid, you get an error message pointing to the exact position of the problem — not a generic “parse error.”
When You Need a JSON Formatter
Developers reach for a JSON formatter dozens of times a week without thinking about it:
- Reading API responses. Tools like
curland Postman return compact JSON. A formatter makes nested payloads readable so you can inspect the data structure and spot missing fields. - Debugging webhook payloads. Incoming webhooks from Stripe, GitHub, or Slack arrive as dense single-line JSON. Formatting them reveals the event structure instantly.
- Cleaning up config files. Files like
package.json,tsconfig.json, or Terraform state files accumulate manual edits. A formatter normalizes indentation across the entire document. - Minifying for production. The reverse operation: stripping whitespace from JSON before embedding it in environment variables, Lambda layers, or inline scripts reduces payload size by 20-40%.
- Comparing payloads. Formatting two JSON blobs with the same indentation makes them diff-friendly — critical for code review and debugging.
Common JSON Errors and How to Fix Them
JSON’s strict syntax catches many developers off guard, especially those coming from JavaScript where the parser is more lenient. Here are the errors this tool catches most often:
Trailing commas. {"name": "Alice", "age": 30,} is valid JavaScript but invalid JSON. Remove the comma before every closing } or ]. This is the single most common JSON error.
Single quotes. JSON requires double quotes for both keys and string values. {'name': 'Alice'} fails — change it to {"name": "Alice"}. If you’re copying from Python’s repr() output or a JavaScript console, watch for this.
Unquoted keys. {name: "Alice"} works in JavaScript objects but not in JSON. Every key must be a double-quoted string: {"name": "Alice"}.
Comments. JSON has no comment syntax. // this is a name or /* block comment */ will cause a parse error. If you need comments in config files, consider JSONC (used by VS Code), JSON5, or YAML instead.
Missing commas. Forgetting the comma between key-value pairs — {"name": "Alice" "age": 30} — produces a cryptic error. The tool points to the exact character where the parser expected a comma.
Number format issues. Leading zeros (0123), hex literals (0xFF), and +Infinity are not valid JSON numbers. Only standard decimal notation is allowed: 123, 1.5, -3, 2.5e10.
JSON vs Other Data Formats
| Feature | JSON | YAML | XML | TOML |
|---|---|---|---|---|
| Readability | Concise, bracket-based | Indentation-based, very readable | Verbose tag-based | INI-style sections |
| Data types | 6 native types | Rich (dates, multiline strings) | All values are strings | Typed (datetime, arrays) |
| Comments | Not supported | # comments | <!-- --> comments | # comments |
| Array syntax | [1, 2, 3] | - item per line | Repeated elements | [1, 2, 3] |
| File size | Compact | Slightly larger | 2-3x larger | Compact |
| Best for | APIs, data exchange | Config files, K8s manifests | Enterprise/document systems | App config (Cargo, Hugo) |
JSON dominates API communication because it maps directly to native data structures in every major language, parses fast, and has an unambiguous spec. YAML and TOML are preferred for configuration where human editing and comments matter. XML persists in enterprise systems, SOAP, and document-oriented workflows where schemas (XSD) and namespaces are required.
JSON Formatting in Other Tools
- This tool — zero-install, instant browser-based formatting with validation, minification, and configurable indentation. Privacy-first: nothing leaves your browser. Best for quick formatting when you don’t want to open an IDE.
- jq — powerful command-line JSON processor.
echo '{"a":1}' | jq .pretty-prints, and jq’s query language lets you filter, transform, and slice JSON. Best for scripting and pipelines. - VS Code — built-in JSON formatting with
Shift+Alt+F. Handles large files well and supports JSONC (JSON with comments). Best when you’re already in the editor. - Prettier — opinionated code formatter with JSON support. Integrates into CI/CD pipelines and pre-commit hooks. Best for enforcing consistent formatting across a team.
- Browser DevTools — Chrome and Firefox display formatted JSON in the Network tab’s Preview pane. Convenient for inspecting API responses during development.
Use this tool when you need a fast, private, copy-paste-and-go formatter without installing anything or switching windows.