JSON Formatter — Free Online Pretty-Print, Minify & Diff
Format and validate JSON instantly. Pretty-print with 2/4/tab indent, minify for transmission, or diff two JSON blobs side-by-side. Everything runs in your browser — your data stays local.
How to format and validate JSON online
- Paste your JSON. Paste raw JSON into the left editor, or drag a .json file into the editor area. Up to 10 MB works smoothly.
- Pick indent style. Choose 2 spaces, 4 spaces, or tab indentation. The formatted output appears live in the right pane.
- Validate. Invalid JSON shows the exact line and column of the error in red, with a one-line explanation of what went wrong.
- Copy, minify, or diff. Copy formatted output, switch to minify mode (single-line output for transmission), or load a second blob into the diff view.
Frequently Asked Questions
- Is my JSON uploaded or logged?
- No. Formatting, validation, and diff run entirely in your browser. Nothing is sent to a server.
- What is the maximum file size?
- Up to ~10 MB performs smoothly. Larger files may slow the editor. For >50 MB consider a CLI tool like jq.
- Does it sort keys alphabetically?
- Yes — toggle the "Sort keys" option to alphabetize object keys recursively. Useful for stable diffs.
- Can it handle JSON5 or JSONC (with comments)?
- Yes — toggle the "Allow comments" option. Output is valid JSON (comments stripped).
- How does the diff view work?
- Load JSON A and JSON B. Differences are highlighted line-by-line. Added keys appear green, removed red, changed yellow.
- Will it preserve number precision?
- JavaScript number precision (53-bit) is preserved. For larger integers (BigInt), use a CLI tool.
Use Cases
- Debug API responses by pretty-printing raw JSON
- Minify JSON config before embedding in HTML or environment variables
- Diff two JSON snapshots to find what changed between deploys
- Validate JSON syntax before pasting into a config file
- Sort object keys alphabetically for stable git diffs
The 6 JSON syntax errors that trip people up most
JSON looks like a JavaScript object literal but follows a stricter grammar (RFC 8259) — most "invalid JSON" reports are one of a handful of repeat offenders, usually from copy-pasting JS code or a trailing comma left over from editing.
| Error | Invalid example | Why it fails | Fix |
|---|---|---|---|
| Trailing comma | {"a": 1, "b": 2,} | JSON has no trailing commas, unlike modern JS | Remove the comma before } or ] |
| Single quotes | {'a': 1} | JSON strings and keys must use double quotes only | Use "a" not 'a' |
| Unquoted keys | {a: 1} | JS object shorthand is not valid JSON | Quote every key: {"a": 1} |
| Comments | {"a": 1 /* note */} | JSON has no comment syntax at all | Delete comments, or use the JSON5/JSONC mode below |
| NaN / undefined / Infinity | {"a": NaN} | These are JS values with no JSON equivalent | Use null, or a sentinel string like "NaN" |
| Leading zeros | {"a": 007} | Numbers cannot have leading zeros | Write 7, or quote it as a string "007" |
- JSON5 and JSONC (JSON with Comments, used by VS Code's settings.json and tsconfig.json) relax several of these rules — trailing commas and comments are allowed — which is why this tool has a separate "Allow comments" toggle rather than trying to guess.