Skip to content

JSON Formatter & Validator

Paste JSON to format, minify or validate it. When something is wrong, the error tells you what — trailing comma, unquoted key, missing value — and shows you exactly where.

Runs in your browser · Files never uploaded
Output style

How to use the JSON formatter

  1. Paste your JSON into the left pane. Validation runs as you type.
  2. Choose an output style — two spaces, four spaces, tabs, or minified.
  3. Read the result. Valid JSON appears formatted on the right, with a structural summary underneath.
  4. If it is invalid, the right pane becomes an error panel naming the mistake, with the line, column, and a caret under the exact character.

Nothing is uploaded. The browser's own JSON engine does the parsing, on your device.

When you would need this

Reading an API response. Responses arrive minified, on one enormous line. Formatting turns that into something a person can navigate.

Finding the error in a config file. An application refuses to start and reports a parse failure with no location. Pasting the file here gives you the line.

Shrinking JSON for production. Minifying strips every unnecessary byte of whitespace, which matters for anything sent over a network repeatedly.

Comparing two documents. Sorting keys on both makes a diff show real differences rather than reordering noise.

Checking a payload before sending it. Confirming a request body is valid before an API rejects it saves a round trip and a confusing error.

The four mistakes that cause almost every JSON error

Trailing commas. This is the big one, and it exists because JavaScript and JSON disagree. {"a": 1, "b": 2,} is a perfectly legal JavaScript object literal and an invalid JSON document. Anyone who writes JavaScript will produce this repeatedly, because the habit is correct in one context and wrong in the other. There is no version of standard JSON that permits it.

Single quotes. JSON strings must be wrapped in double quotes. {'name': 'value'} is valid JavaScript and invalid JSON, for both the key and the value. This one catches people copying object literals out of code.

Unquoted property names. {name: "x"} is legal JavaScript. In JSON, keys are strings, and strings need double quotes: {"name": "x"}.

Missing or extra values. {"a": ,} and [1, , 2] both fail. JSON has no concept of an empty slot — where JavaScript arrays can be sparse, JSON arrays cannot.

Notice the pattern: every one of these is a place where JavaScript is more permissive than JSON. JSON was derived from JavaScript's object syntax but is a strict subset of it, and the gap between them is where most errors live.

Any value can be the top level. 42, "hello" and null are all complete, valid JSON documents. It does not have to be an object or an array, though older parsers sometimes insisted.

Duplicate keys are not an error. {"a": 1, "a": 2} parses, and the last value wins. The specification does not forbid duplicates, though it warns the behaviour is implementation-defined. If you see a key mysteriously holding the wrong value, look for a second copy of it.

There are no comments. Not //, not /* */. This is a deliberate design decision by JSON's author, on the grounds that comments were being used to carry parsing directives. Formats like JSONC and JSON5 add them back, and are not JSON.

Numbers have limits. JSON permits arbitrary precision, but JavaScript parses numbers as 64-bit floats. Integers beyond about 9 quadrillion lose precision silently — which is why APIs handling large IDs usually send them as strings.

Trailing zeros vanish. 1.0 parses to the number 1 and re-serialises as 1. The value is the same; the text is not.

Limits and requirements

Strict JSON only. Comments, trailing commas and single quotes are reported as errors rather than silently accepted, because a validator that accepts them is lying to you about whether your file will work elsewhere.

Large documents use memory. The whole structure is parsed into memory at once. Tens of megabytes will work but feel slow; hundreds may fail. That is a property of parsing rather than of this tool.

Number precision follows JavaScript. Very large integers lose precision on parse. If you need them intact, they must be transmitted as strings.

Key order is preserved unless you sort. Object key order is not meaningful in JSON, but it is preserved here so that formatting does not shuffle your document unexpectedly.

Browser support. Any modern browser on desktop or mobile. JavaScript must be enabled.

Privacy: how this tool handles your JSON

Everything happens on your device. The browser's own JSON.parse does the work in your tab, and the result never leaves it.

This is worth stating plainly for this tool in particular. Consider what actually gets pasted into JSON formatters: production API responses containing real names, addresses and order histories. Configuration files with database connection strings in them. Decoded token payloads carrying live session claims. Firebase or AWS credentials embedded in a config block.

A server-side formatter receives all of it, and what happens next depends on logging practices you cannot inspect — request bodies written to access logs, captured by error trackers, retained in backups. It does not require anyone to act in bad faith. Pasted secrets have been recovered from the caches of public formatting services more than once.

You can check this rather than trusting it. Open your browser's developer tools, switch to the Network tab, and paste something in. No request carries your data. Or disconnect from the internet entirely after the page loads and keep using it — it works, because there is nowhere else for the parsing to happen.

Frequently asked questions

Is the JSON I paste sent anywhere?

No. Parsing and formatting happen in your browser using its built-in JSON engine. Nothing is transmitted, logged or stored. This matters more for JSON than for most formats, because the JSON developers paste into formatters is routinely an API response containing real customer records, a config file with credentials in it, or a token payload. Any formatter that posts your input to a server is a data exfiltration risk, and plenty of them do.

Why are the error messages different from what my editor shows?

Because the browser's own message is usually unhelpful. JavaScript engines report something like 'Unexpected token } in JSON at position 214', which tells you almost nothing in a 600-line file. This tool works out what is actually wrong by examining the source around the failure — a comma before a closing brace is a trailing comma, an identifier followed by a colon is an unquoted key — and reports that instead, with a line, a column and the offending line shown.

What is the most common JSON error?

A trailing comma, by a wide margin. JavaScript object literals allow a comma after the last item and JSON does not, so anyone who writes JavaScript produces this mistake regularly. The second most common is single quotes: JSON strings must use double quotes, always, with no exceptions. Third is unquoted property names, which JavaScript permits and JSON forbids.

Does formatting change my data?

Only its whitespace and key order, and key order only if you ask. Values are parsed and re-serialised, so the data is identical. One thing to be aware of: numbers are normalised by the parser, so 1.0 becomes 1 and 1e3 becomes 1000. The values are equal, but the text is not byte-identical to what you pasted.

What does sorting keys do, and why would I want it?

It orders every object's keys alphabetically, recursively. The reason is diffing: two JSON documents describing the same thing often differ only in key order, which makes a line-by-line diff useless. Sorting both first reduces the diff to real differences. Array order is deliberately left alone, because in an array the order is data, not formatting.

Is there a size limit?

None imposed by us, since nothing is uploaded. The practical limit is your device's memory. Very large documents — tens of megabytes — will take a moment to parse and may feel sluggish, because the whole structure is held in memory at once. Files that large are usually better handled by a streaming parser than by any browser tool.

Can it handle JSON with comments or trailing commas?

No, and that is deliberate. Those are JSON5 or JSONC — different formats that happen to look similar. Standard JSON permits neither, and a validator that quietly accepted them would tell you your file is fine when the system you are sending it to will reject it. The error message names the problem so you can fix it.

What do the statistics at the bottom mean?

A quick structural summary: how many nodes the document contains, how many object keys, how many array items, and how deeply it nests. Depth is the useful one — deeply nested JSON is harder to work with and often indicates a structure that would be simpler flattened.

Written and maintained by Prashant ShekharLast updated