JSON Formatter, Validator & Fixer
Format, validate, minify, and automatically fix broken JSON instantly in your browser. Your data never leaves your device.
Paste, type, or upload JSON to get started.
Whether you're debugging an API response, cleaning up a config file, or just trying to read a wall of minified JSON, this tool formats, validates, minifies, automatically repairs broken syntax, and inspects JSON with a colorful tree view - entirely in your browser, with your data never uploaded anywhere.
How JSON formatting works
"Formatting" (or pretty-printing) doesn't change the data at all - it only changes the whitespace, adding indentation and line breaks so nested structure is easy to read. Under the hood this tool uses JSON.parse() to read your JSON into a real JavaScript value, then JSON.stringify() to write it back out with your chosen indentation (or none, for minifying).
Why JSON validation matters
A single stray comma or missing quote makes an entire JSON document unreadable to any program expecting to parse it - and the resulting error messages are often unhelpful on their own. This tool points to the exact line, column, and character where parsing failed, so you can find and fix the problem directly instead of scanning by eye.
Automatically fixing broken JSON
When your JSON is invalid, the Fix JSON button attempts to repair it automatically - handling the most common problems in one click: missing or trailing commas, missing closing brackets/braces, unquoted object keys, single-quoted strings, and stray comments. Afterward it shows a short summary of what it believes it changed, so a fix is never a silent black box. If the JSON is too badly broken to recover, it says so plainly rather than guessing at something that isn't there.
Pretty print vs minify
Pretty-printed JSON is for humans - indentation and line breaks make structure easy to follow while editing or reviewing. Minified JSON strips all of that whitespace, producing the smallest possible file - better for what you actually send over a network or store, since the extra formatting characters serve no purpose there.
Common JSON mistakes
- Trailing commas after the last item in an object or array - valid in JavaScript object literals, but not in JSON. (Auto-fixable.)
- Using single quotes instead of double quotes - JSON strings must use double quotes. (Auto-fixable.)
- Leaving a comment in the file - JSON has no comment syntax at all. (Auto-fixable.)
- Missing a closing bracket or brace, especially in deeply nested structures. (Auto-fixable.)
- Duplicate keys in the same object - technically parseable (the last one silently wins), but almost always a mistake worth fixing. This one isn't something "Fix JSON" changes, since it's valid syntax - the duplicate-key warning flags it instead.
Best practices
- Keep nesting as shallow as practical - deeply nested JSON is hard for humans to read and easy to make mistakes in.
- Use consistent key naming (e.g. always camelCase or always snake_case) throughout a document.
- Minify JSON before sending it over a network; keep a pretty-printed copy for editing.
Frequently asked questions
Why does my JSON say "Unexpected token" but I can't find the problem?
Check the line and column this tool reports - the error usually points at, or just after, a missing comma, quote, or bracket immediately before that position.
Are trailing commas ever allowed in JSON?
No - unlike JavaScript object/array literals, standard JSON never allows a trailing comma before a closing } or ].
What happens if my JSON has duplicate keys?
It still parses - JavaScript keeps only the last value for a repeated key and silently drops the earlier ones. This tool detects and warns about that rather than failing, since it's technically valid but usually unintentional.
What's the difference between formatting and validating?
Validating just checks whether the JSON is syntactically correct. Formatting also rewrites its whitespace for readability - you can't format invalid JSON, since there's no valid structure to lay out.
Is my JSON uploaded anywhere?
No - parsing, formatting, and minifying all happen locally using your browser's own JSON engine.
Can this tool fix broken JSON automatically?
Yes - the Fix JSON button (enabled whenever the JSON is invalid) handles common problems like missing commas, missing brackets, unquoted keys, and single quotes, then shows a short summary of what it changed. Severely malformed input may still be beyond automatic repair.
Related tools
Browse the rest of the Developer tools on NeatSize.
Runs entirely in your browser - nothing you enter or upload is sent to a server.
Need it to do something else? Request a tool