Free tool · Nothing uploaded

JSON formatter

Format, minify and validate — and when it is invalid, theexact line and column with a caret under it and a sentence naming the mistake. Browsers do not give you that for the errors people actually make, so this works it out itself.

Your JSON

Arrays keep their order — reordering one would change your data. Nothing is uploaded.

Result

Paste some JSON.

Why the error message here is different

Paste broken JSON into a browser console and you get one of two things. For some mistakes: "Expected double-quoted property name in JSON at position 22 (line 4 column 1)" — useful. For others, including the most common ones: "Unexpected token ''', ...'"b": 'two'' is not valid JSON" — a snippet, and no position at all.

Which mistakes fall into which bucket differs between V8, Firefox and Safari. A tool that reads the position out of that message therefore works for some errors, in some browsers, and silently does not the rest of the time — which is worse than not offering it, because it looks like it works.

So this page does not read the browser's message for the position. It scans the document against the JSON grammar itself and reports where the first violation is. Same answer in every browser, and it can say what itexpected there rather than what it tripped over. The scanner was checked against JSON.parse on 45 documents, valid and invalid, with no disagreement about which is which.

The three mistakes that account for most of it

Nearly every hand-edited JSON failure is one of these, and all three are valid JavaScript — which is exactly why they slip through.

A trailing comma

{"a": 1, "b": 2,}. Perfectly fine in a JavaScript object literal and forbidden in JSON. It is the most common one by a distance, because it survives every edit that adds or removes the last entry.

Single quotes

{'a': 1}. JSON strings — keys included — must be double quoted. There is no option and no dialect where this is allowed.

An unquoted key

{a: 1}. Again ordinary JavaScript, and again not JSON. Every key is a string, even when it is a plain word with no spaces in it.

Two more that catch people less often but are harder to spot:NaN and Infinity are not JSON values (usenull), and comments are not allowed — no//, no /* */. That last one is why JSON5, JSONC and YAML exist.

Why "nothing is uploaded" matters here specifically

More than for most tools on this site. The JSON people paste into a formatter is almost never a toy: it is an API response caught mid-debug, and it routinely contains bearer tokens, session identifiers, customer email addresses, internal IDs and the shape of a private schema.

A formatter that posts that to a server has been handed all of it. Nothing here leaves the page — and you do not have to take that on faith, because the Network tab settles it in two minutes for this tool or any other.

Questions

Why is my trailing comma an error?

Because JSON's grammar has no trailing commas, while JavaScript's does. The text looks right in an editor and only fails when something parses it as JSON.

Can I put comments in JSON?

No. Not //, not /* */. If you need comments in a config file, that file wants to be JSON5, JSONC or YAML.

Does sorting keys change anything?

No — object keys have no defined order. Arrays are never reordered, because their order is the data.

Is my JSON sent anywhere?

No. It runs entirely in your browser, which matters here because API responses tend to carry tokens and customer data.

More free tools

Colour contrast checker · Image compressor · Random picker · Password generator · Unit converter

All free, all running entirely in your browser. Built by Maxverse Lab, a software studio in Karachi.