What is a JSON Formatter?
A JSON Formatter (also called a JSON Beautifier or JSON Prettifier) takes compact or messy JSON and reformats it with consistent indentation so it’s easy to read. This tool formats, validates and minifies JSON directly in your browser — no data is ever uploaded to a server.
How to Use
- Paste your JSON into the input box on the left
- Click Format (2 spaces) or Format (4 spaces) to prettify
- Click Minify to produce compact, whitespace-free JSON
- Click Copy to copy the output to your clipboard
The validator runs automatically as you type, showing a green ✓ for valid JSON or a red ✗ with the error position for invalid input.
JSON Format Rules
Valid JSON must follow these rules:
- Keys must be strings wrapped in double quotes:
"name", notname - Values can be strings, numbers, booleans (
true/false),null, arrays or objects - No trailing commas —
{"a":1,}is invalid - No comments — JSON does not support
//or/* */comments - Strings use double quotes — single quotes are not valid JSON
Common JSON Errors
| Error | Example | Fix |
|---|---|---|
| Missing quote on key | {name: "Alice"} | {"name": "Alice"} |
| Trailing comma | [1, 2, 3,] | [1, 2, 3] |
| Single quotes | {'key': 'value'} | {"key": "value"} |
| Undefined value | {"x": undefined} | Remove or use null |
| Comments | {"a":1 // comment} | Remove comments |
When to Use Minification
Minified JSON removes all spaces, tabs and newlines to produce the most compact representation. Use it when:
- Sending JSON over an API to reduce payload size
- Storing JSON in a database or config file to save space
- Embedding JSON in a URL or HTML attribute
JSON vs JavaScript Object Literals
JSON looks similar to JavaScript objects but has stricter rules. A JavaScript object allows unquoted keys, single quotes and trailing commas — none of which are allowed in JSON. When copying a JavaScript object to use as JSON, you must:
- Wrap all keys in double quotes
- Replace single-quoted strings with double-quoted strings
- Remove trailing commas
- Replace
undefinedvalues withnullor omit the key
Formatting Large JSON Files
If your JSON is very large, the formatter may take a moment. For files over 1 MB, consider using a command-line tool like jq:
cat data.json | jq .
For small and medium JSON (under ~500 KB), this browser-based tool is fast and convenient.
Privacy
All processing happens in your browser using JavaScript’s built-in JSON.parse() and JSON.stringify(). Your JSON is never sent to any server, stored, or logged. You can even use this tool offline once the page has loaded.