Skip to content

JSON Formatter and Validator

Paste some JSON and know right away whether it is valid. If it is, see it neatly indented the way you like, or minified on one line, with its keys sorted if you ask. If it is not, the tool tells you the line and column of the problem and what is missing: a comma, a quote, a brace. It all happens in your browser.

Works anywhere in the world, wherever you are.

What to do
Sort keys
Indentation

Status

Waiting for JSON

Paste or type some JSON and it is checked instantly.

Formatted JSON

The formatted JSON shows up here once the text is valid.

Your JSON never leaves your device: it is read and formatted in your browser, is not in the Share link, is not saved and is not sent to any server or to analytics. Close or reload the page and it is gone.

About this calculator

How to use it

Paste or type the JSON in the box. The status updates as you type: "Valid JSON", or "Syntax error" with the line and column. Choose "Format" to indent it with 2 spaces, 4 spaces or a tab, or "Minify" to strip every space and line break it does not need.

"Sort keys A → Z" orders the keys of every object, at every level, by Unicode code point (capitals before lowercase, as jq -S does). Arrays are not reordered, because in JSON their order is part of the data.

"Copy result" puts the JSON on your clipboard and "Download .json" saves it as a file. Below you see the size before and after, the lines, the nesting levels and how many keys, objects and arrays it holds.

Example

The JSON {"product":"coffee","price":4.5,"inStock":true,"sizes":["S","M"]} takes 65 bytes on one line. Formatted with 2 spaces it takes 9 lines and 95 bytes, with 3 nesting levels and 4 keys. Minified, it goes back to its 65 bytes.

Type {"product": "coffee", "price": 4.50,} and the tool shows "Syntax error: Line 1, column 36", explaining that the comma is extra: in JSON the last item of an object or array takes no comma, even though JavaScript allows one.

The most common mistakes

An extra comma at the end, or a missing comma between two items. When the comma is missing at the end of a line, the error is marked on the next line, where the next item starts: that is where a reader notices it is missing.

Single quotes ('text') or unquoted keys ({name: 1}). That is JavaScript, not JSON: JSON only takes double quotes, keys included.

Comments (// or /* */), values such as undefined, NaN or a capitalized True, numbers with leading zeros (007) or with no digit beside the point (.5 or 5.). None of them is valid JSON.

A line break inside a string. It nearly always means the closing quote on that line is missing; if the break belongs to the text, it is written \n.

What is kept exactly as written

Many formatters read the JSON with JavaScript and write it back out, changing things on the way: they move keys that look like numbers ("10", "2") to the front of the object, keep only the last of two repeated keys and round big numbers. This one does not: key order, repeated keys and every number and string come out exactly as you wrote them. Only whitespace changes and, if you ask, the order of the keys.

For example, in {"id": 12345678901234567890} JavaScript would read 12345678901234567000. Here the number stays the same, and the tool warns that it has more precision than JavaScript and many languages can hold. If it is an identifier, the safe choice is to store it as a string in quotes.

Repeated keys are valid JSON, but every program handles them its own way (most keep the last value), so they are flagged too, with their line and column.

Your JSON stays with you

The JSON is read and formatted entirely in your browser, with the browser's own JSON reader (JSON.parse) plus a strict one that pinpoints errors; it is never run as code. It is not sent to any server, is not in the "Share" link, is not saved on your device and is not recorded in the site's statistics. Reload or close the page and it is gone. Even so, avoid pasting passwords or API keys into any online tool.

Important limitations

  • It validates JSON syntax (RFC 8259), not content: it does not check a schema (JSON Schema), whether the fields you expect are there, or their types.
  • It does not accept JSON5, JSONC or other variants with comments, trailing commas or single quotes; it flags them as errors. Nor does it read JSON Lines (one object per line): that shows up as extra content after the first object.
  • It reports only the first error. Once you fix it, the next one may appear.
  • The column counts JavaScript characters (UTF-16), like most editors; an emoji counts as 2.
  • It reads up to 1,000 levels of nesting. For very large JSON, the page shows the first 100,000 characters of the result; copy and download carry the full JSON.

Frequently asked questions

No. It is read and formatted in your browser: it is not sent, not stored, not in the Share link and not sent to analytics. Close the page and it is gone.

The tool gives the exact line and column, shows that line with a ^ under the spot and explains what is missing or extra. If a comma is missing at the end of a line, the mark shows on the next one, where the next item starts.

Formatting adds line breaks and indentation so the JSON is easy to read. Minifying strips every space it does not need, so it weighs less to send or store. The data is the same either way.

Because JSON only accepts double quotes, for strings and keys alike. {'a': 1} is fine in JavaScript or Python, but in JSON it is written {"a": 1}.

It does not change any value, only the order the keys of each object appear in. Arrays keep their order, because there the order is part of the data.

This calculation runs in your browser and is never sent to a server. Your last values may be saved on your device only, for convenience. Results are estimates and are not financial, tax, accounting or legal advice.