JSON Formatter

JSON formatter & validator

Beautify, validate, and minify JSON. Paste it in, pick your indentation, and copy clean output.

▌ JSON in
▌ Output

Format, validate, or minify

Paste JSON and tap Format to pretty-print it with clean indentation, or Minify to strip every unnecessary space for production. If the JSON is malformed, you get a clear error pointing at the problem instead of a silent failure. It all runs in your browser, so even config files or API responses with sensitive values never leave your device.

Why formatting matters

Minified JSON — one long line with no spaces — is efficient for machines but nearly unreadable for people, which makes debugging an API response or a config file painful. Pretty-printing restores the structure: indentation shows nesting at a glance, so you can see which fields belong to which object and spot a missing or misplaced value quickly. When you're done reading, minifying again shrinks the payload for transmission, where every byte counts.

Catching the common mistakes

Most JSON errors come from a handful of culprits: a trailing comma after the last item, single quotes instead of double quotes, unquoted keys, or a missing bracket. JSON is stricter than JavaScript object syntax, which trips people up constantly. Running text through the formatter is the fastest way to confirm it's valid before you paste it somewhere that will reject it less helpfully. Need to turn that JSON into a spreadsheet? The JSON to CSV converter handles arrays of objects.

What makes JSON invalid

JSON is far stricter than JavaScript object literals, and almost every parse error comes from the same handful of habits:

  • Trailing commas. {"a":1,} is valid JavaScript and invalid JSON. This is the most common error by a wide margin.
  • Single quotes. Strings and keys must use double quotes, so {'a':1} fails.
  • Unquoted keys. {a:1} is fine in JavaScript, not in JSON.
  • Comments. JSON has none. // and /* */ are both parse errors, which is why config formats like JSON5 and JSONC exist.
  • Stray values. NaN, Infinity and undefined are not JSON; use null.

Unescaped control characters inside strings are the subtler one — a literal newline inside quotes must be written as \n.

Numbers, and where precision goes

JSON does not distinguish integers from floats; there is one number type, and no explicit precision limit in the specification. In practice most parsers map numbers onto a 64-bit float, which safely represents integers only up to 2⁵³ − 1.

That is why large identifiers — database primary keys, Twitter-style snowflake IDs — get silently rounded when they travel as JSON numbers. The conventional fix is to transmit them as strings. If an ID ends in an unexpected 0 after a round trip, this is almost always why.

Minify, format, and what to commit

Minifying strips whitespace for transport, which matters over the wire; formatting adds it back for humans. Neither changes the data, so you can move between them freely.

For files kept in version control, prefer formatted JSON with a consistent key order. A minified file shows up as a single changed line in every diff, which makes review nearly impossible, whereas a pretty-printed one produces a readable line-by-line diff. If you need to compare two versions by hand, format both first and then use the diff checker. To reshape tabular JSON, the JSON to CSV converter handles the conversion.

FAQ

Is my JSON uploaded anywhere?
No. Parsing and formatting happen entirely in your browser — safe for sensitive data.
What does minify do?
It removes all unnecessary whitespace and line breaks, producing the smallest valid JSON for faster transfer.
Why is my JSON invalid?
Most often a trailing comma, single quotes instead of double, unquoted keys, or comments — all legal in JavaScript but not in JSON. NaN, Infinity and undefined are also invalid; use null instead.
Can JSON have comments?
No. The JSON specification has no comment syntax, so both // and /* */ cause a parse error. That gap is exactly why variants like JSON5 and JSONC exist for configuration files where comments are useful.
Why do large numbers lose precision in JSON?
JSON has a single number type and most parsers map it onto a 64-bit float, which represents integers exactly only up to 2^53 - 1. Larger identifiers get rounded, so the usual fix is to send big IDs as strings rather than numbers.

Related tools