JSON Formatter & Validator

Paste JSON to format it with 2-space indentation, or minify it — invalid JSON shows a clear error.

Copied ✓
AdvertisementAd slot #1 · below the result

What it does

Paste any JSON into the box and choose Format to pretty-print it with two-space indentation, or Minify to strip all whitespace and produce the smallest possible string. If the input is not valid JSON, a clear error message appears so you know exactly what went wrong. Everything runs in your browser — nothing you type is sent anywhere.

Why formatting matters

Readability. Machine-generated JSON often arrives as one long line. Formatting expands it into a human-readable tree where nesting is immediately visible. This is invaluable when reading API responses, config files, or debugging output.

Wire size. The opposite is also true: before sending JSON over the network or storing it in a database, minifying it removes every whitespace character that a machine does not need. A deeply nested document can shrink by 20–30% after minification.

What “valid JSON” means

JSON has a strict grammar defined by RFC 8259. The most common mistakes that make JSON invalid are:

  • Trailing commas{"a":1,} is invalid; the comma after the last item is not allowed.
  • Single quotes — strings must use double quotes. {'a':1} is not valid JSON (though it is valid JavaScript).
  • Unquoted keys — every key must be a quoted string. {a:1} is invalid.
  • Comments — JSON has no comment syntax; // comment or /* */ cause a parse error.
  • Undefined, NaN, Infinity — these JavaScript values have no JSON representation; only numbers, strings, booleans, null, arrays, and objects are allowed.

Worked example

Formatting {"a":1} with two-space indentation produces:

{
  "a": 1
}

Minifying that result back produces {"a":1}.

Frequently asked

Does this tool modify my data?

No. Formatting and minifying only change whitespace. The values, keys, and structure of the JSON are identical before and after.

What indentation style does it use?

Two spaces per level, which is the most widely used style and matches the default for JSON.stringify(value, null, 2) in JavaScript.

Will it handle large JSON files?

Yes, up to the limits of your browser's memory. For files of tens of megabytes the browser may pause briefly, but there is no server round-trip to worry about.

Why does it show an error for my JSON?

The error message comes directly from the browser's JSON parser and identifies what it found unexpected. The most common causes are the ones listed above: trailing commas, single quotes, or unquoted keys. Fixing those usually resolves the error immediately.

AdvertisementAd slot #2 · after the explainer