JSON Formatter & Validator

Format, validate, minify and sort JSON with precise error messages — entirely in your browser.

🔒 100% private — files are processed on your device and never uploaded to any server.

Make JSON readable, valid and ready to ship

JSON runs the modern web — every API response, config file and data export speaks it — and yet it arrives in two equally hostile forms: minified single-line bricks impossible to read, and hand-edited files broken by one trailing comma. This tool handles the full round trip: paste anything JSON-shaped and format it into indented, readable structure; validate it with a precise error message when it's broken; minify it back for production; and optionally sort keys alphabetically for clean diffs.

How to format or validate JSON

  1. Paste your JSON — an API response, config file, log payload.
  2. Pick indentation (2 spaces, 4 spaces, or tabs) and whether to sort keys.
  3. Click Format / validate for pretty output, or Minify for the compact form.
  4. Valid input gets a green confirmation; broken input gets the parser's exact complaint.

Decoding the error messages

The validator is the same strict parser browsers use, and its messages point at real positions. The lifetime-statistics offenders: trailing commas ({"a":1,} — legal in JavaScript, fatal in JSON), single quotes ('key' instead of "key"), unquoted keys ({key: 1}), comments (JSON has none, by design), and smart quotes smuggled in by word processors. When the reported position seems wrong, look one character earlier — parsers complain where they got confused, which is usually just after the actual mistake.

Sort keys: the diff-maker's secret

JSON objects have no guaranteed key order, so two semantically identical files can differ on every line — making version-control diffs useless. Sorting keys alphabetically (recursively, through nested objects) normalises both files into a canonical form whose diffs show real changes only. Sort before committing config files and the next code review thanks you. The same trick makes API responses comparable across environments: format + sort both, then run them through our Text Compare tool.

Format vs minify: both directions matter

  • Format for humans: debugging API responses, reading configs, documenting payloads. 2-space indent is the ecosystem default; tabs suit accessibility preferences.
  • Minify for machines: strips every needless byte for production payloads and config-embedding — typically 20–40% smaller than formatted.
  • The privacy point is not optional here: API responses routinely contain tokens, emails and customer data. This tool parses entirely in your browser — pasting a payload into a server-side formatter is a data leak; here it isn't.

Paste the brick, read the structure; paste the breakage, read the diagnosis — JSON's two daily miseries, solved on one page.

Quick reference

PropertyDetail
OperationsFormat, validate, minify, sort keys
Indentation2 spaces / 4 spaces / tabs
ValidationStrict JSON.parse with exact error messages
Key sortingRecursive, alphabetical — canonical diffs
Typical minify saving20–40% vs formatted
PrivacyPayloads never leave the browser
CostFree, unlimited

Frequently asked questions

Why is my JSON invalid when JavaScript accepts it?

JSON is stricter than JavaScript object syntax: no trailing commas, no single quotes, no unquoted keys, no comments. The error message names the first violation — fixing the classic trailing comma resolves half of all cases.

What does sorting keys actually do?

It rewrites every object with keys in alphabetical order (recursively), producing a canonical form. Two files with the same data then format identically — version-control diffs and side-by-side comparisons show only real differences.

Is it safe to paste API responses with tokens in them?

Here, yes — parsing happens in your browser's memory and nothing is transmitted. That's a genuine differentiator: pasting secrets into server-side formatter sites leaks them by definition.

Can it handle large files?

Multi-megabyte payloads parse fine — the limit is your browser's memory, far beyond any sane API response. Extremely deep nesting renders slower in the output box but parses correctly.