JSON Formatter / Validator
Free online JSON formatter and validator. Pretty-print, minify, and validate JSON with clear error messages, entirely in your browser.
JSON vs. a JavaScript object literal
Most "invalid JSON" surprises come from the fact that JSON is a stricter subset of what JavaScript itself will accept as an object literal. Object keys must be double-quoted strings — `{name: "x"}` and `{'name': "x"}` are both valid JS but invalid JSON; only `{"name": "x"}` parses. Trailing commas after the last item in an array or object are allowed in modern JavaScript but rejected by JSON.parse. Comments aren't part of the JSON spec at all, in any form. This tool surfaces the raw JSON.parse() error message specifically because that message usually names the exact character position where parsing broke, which is the fastest way to find a stray comma or unquoted key in a large document.
Format vs. Minify — when to use each
Format (pretty-print) adds 2-space indentation and line breaks, which is what you want while reading or editing a document by hand — a nested API response, a config file, a payload you're debugging. Minify strips every byte of non-essential whitespace, which is what you want when the JSON is headed somewhere size matters — embedding in a URL parameter, storing in a database column, or shipping over the wire where every byte counts. Re-parsing and re-serializing is also a quick way to normalize formatting inconsistencies (mixed tabs/spaces, inconsistent key ordering isn't changed, but whitespace is) between two files that should otherwise be identical.