Free & unlimited

JSON Formatter & Validator

Format, validate, and minify JSON instantly in your browser.

What this tool does

Validates JSON and pretty-prints it with proper indentation, or minifies it down to a single line. If the JSON is invalid, it shows the error message from your browser's JSON parser so you can find and fix the problem.

The tool runs in your browser and uses JavaScript's built-in JSON support, so nothing you paste is uploaded. Because it parses the JSON and writes it out again, the output is not a character-for-character copy of your input; the FAQ below lists exactly what can change.

How to use this tool

1Paste your JSON into the input box — a single object, an array, or a full API response.
2Click Format for readable indented output, or Minify to strip all whitespace into one line.
3If it's invalid, read the error message — it describes what went wrong, and many browsers also show where.
4Copy the result with the Copy button.

Why valid-looking JSON gets rejected

Strict JSON is a stricter format than a JavaScript object literal. These are the usual culprits:

  • Trailing commas — a comma after the last item in an object or array is fine in JS, invalid in JSON.
  • Single quotes — JSON requires double quotes for both keys and string values.
  • Unquoted keys — {name: "x"} must be {"name": "x"}.
  • Comments — neither // nor /* … */ is allowed anywhere in JSON.
  • Stray values — undefined, NaN, and Infinity aren't valid; a leading zero or a hanging decimal point breaks a number.

Format makes JSON readable for debugging; Minify shrinks it for storage or transport, where every byte over the wire counts. The syntax rules above come from the JSON standards listed under Sources.

FAQ

It says my JSON is invalid but it looks fine — why?
Almost always a trailing comma, a single quote where a double quote is required, an unquoted key, or a comment. The error message comes from your browser's JSON parser and its wording varies between browsers; some include a position, others only name the unexpected token.
What's the difference between Format and Minify?
Format adds newlines and two-space indentation so it's readable. Minify removes every optional space and newline to make the smallest possible valid JSON. Both go through the same parse and re-write step, so the changes listed in the next answer apply to each.
Does formatting change my data or reorder keys?
It can. The tool parses your JSON with JSON.parse and writes it back with JSON.stringify, so: (1) keys that look like whole numbers (such as "1" or "42") move to the front in ascending order, while other keys keep their order; (2) if a key appears twice, only the last value is kept; (3) numbers are read as 64-bit floating-point values, so 1.0 becomes 1, 1e2 becomes 100, -0 becomes 0, and integers beyond about 15 to 17 significant digits are rounded (12345678901234567890 becomes 12345678901234567000). Strings, true, false, null and the nesting are kept. If you need byte-exact output, use a tool that edits the text without parsing it.
Is there a size limit?
No hard limit, but very large input (tens of megabytes) can be slow or memory-heavy since it all parses in your browser tab.
Why are some of my keys listed in a different order?
JSON objects are unordered by definition, and in JavaScript, keys that are whole-number strings are always listed first in ascending order, ahead of the other keys. The formatter relies on that built-in behaviour, so it shows up in the output. Arrays are never reordered.

Sources

Syntax rules come from the JSON standards. The key-ordering and number behaviour described above comes from JavaScript's built-in JSON methods.

  1. Bray, T. (Ed.) (2017). “The JavaScript Object Notation (JSON) Data Interchange Format (RFC 8259).” IETF. rfc-editor.org/rfc/rfc8259 — Grammar: no trailing commas or comments, double-quoted strings, no leading zeros, no NaN or Infinity; also warns that duplicate names and large numbers behave unpredictably.
  2. Ecma International (2017). “ECMA-404: The JSON data interchange syntax, 2nd edition.” Ecma International. ecma-international.org/publications-and-standards/standards/ecma-404 — The second standard definition of valid JSON text.
  3. Ecma TC39 “ECMAScript Language Specification, OrdinaryOwnPropertyKeys.” ECMA-262. tc39.es/ecma262/#sec-ordinaryownpropertykeys — Why whole-number keys are listed first, in ascending order, when an object is written back out.

Last reviewed: October 2026