Blog

How to Format and Validate JSON Online

Published August 2026 · Toolsyy Team

An API returns one enormous line of JSON and you need to find one field in it. Or a config file won’t load and the error says nothing useful. Toolsyy’s JSON Formatter & Validator indents it, minifies it, or tells you exactly which line is broken — in your browser, so you can safely paste a response containing real credentials.

The four things JSON doesn’t allow

Nearly every “but it looks fine!” error is one of these. All four are perfectly legal JavaScript, which is exactly why they catch people out — you write JSON in a JavaScript editor, and the editor doesn’t complain.

1. Trailing commas

{
  "a": 1,
  "b": 2,
}

That last comma is fatal. JavaScript tolerates it; JSON does not. It’s the most common JSON error there is, and it usually appears after someone deletes the final property.

2. Single quotes

JSON requires double quotes, for both keys and string values. {'a': 1} is invalid; {"a": 1} is correct.

3. Unquoted keys

{a: 1} is a valid JavaScript object but not valid JSON. Every key must be a quoted string.

4. Comments

JSON has no comments at all — neither // nor /* */. This trips people up constantly in config files. The usual workaround is a real key such as "_comment" that the consuming program ignores.

Two smaller ones worth knowing: NaN and Infinity are not valid JSON numbers, and a number may not have a leading zero, so 007 must be written as the string "007".

Reading the error message

Browsers report JSON errors in a way that is technically accurate and practically useless — often quoting a fragment of your document without saying where it is. Toolsyy translates that into a line number:

Expected double-quoted property name — line 4, column 1

That points straight at a trailing comma on the line above. When the browser gives a precise position you get an exact line and column; when it only gives a fragment, you get near line N, which is still enough to find it in a long file.

One error message means something different from the rest: Unexpected end of JSON input. That isn’t a mistake on a particular line — it means the document simply stops early. The usual cause is a truncated download or a response that got cut off, not a typo.

Beautify, minify, and sorting keys

  • Indent (2 spaces, 4 spaces or tab) makes a machine-generated blob readable. The structure counters above the output — values, depth and byte size — give you a quick sense of what you’re looking at before you read it.
  • Minified strips every space and newline outside strings. On a large payload that’s frequently 20–30% of the size, which is worth having on an API response served thousands of times a day.
  • Sort keys alphabetically is the underrated one. Two JSON documents that contain the same data but list keys in different orders produce a huge, unreadable diff. Sort both and the diff shows only what genuinely changed. Arrays are never reordered, because their order is real data.

FAQ

Why is my JSON invalid when it looks fine?

The four most common causes are a trailing comma after the last item, single quotes instead of double quotes, unquoted property names, and a comment. All four are legal in JavaScript but forbidden in JSON, which is why code that works in an editor can still fail to parse.

Does sorting keys change what the JSON means?

No. Object key order is not significant in JSON, so sorting keys alphabetically produces an equivalent document. Array order is significant and is never changed, because reordering an array would genuinely change the data.

What does minifying JSON actually save?

It removes every space and line break outside of strings. On a large document that is often twenty to thirty percent of the size, which matters for an API response sent thousands of times. It makes no difference to how the data is interpreted.

Is my data sent anywhere when I paste it here?

No. Formatting and validation run entirely in your browser using the built-in JSON parser. Nothing is transmitted or logged, so it is safe to paste an API response containing real keys or customer data.

Related guides

Try it now: Free JSON Formatter & Validator