JSON → formatted

JSON formatter and validator

Paste JSON to validate it, pretty-print it with your indentation, minify it or sort its keys — with the exact line and column when it is broken.

Paste JSON or load a .json file.

Parsing and formatting happen in this tab. Your JSON never leaves your device, and the downloaded file is written from the browser's own memory.

Short answer: paste JSON above and the formatted result appears as you type. If it is invalid you get the line, the column and the reason — not a generic "invalid JSON" message. Use Minified to strip every optional space, and Sort keys to make two files diffable.

What the formatter changes, and what it does not

The browser parses the document with JSON.parse and prints it again. That means numbers, strings and booleans are preserved exactly as written — 1e3 becomes1000 and 1.50 becomes 1.5, because both spell the same value and JSON has one canonical number form. Whitespace and (optionally) key order change. Nothing else does.

Object keys that appear twice collapse to the last value, which is the behaviour every JSON parser has. The tool does not warn about duplicates, because by the time the document is parsed the earlier value is already gone; use a linter if duplicate keys matter to you.

Why validate in the browser

Configuration files, API responses and fixtures routinely contain tokens, internal hostnames and customer data. Uploading them to a formatter means handing that to a third party and hoping they delete it. This page has no upload endpoint: the network panel shows only the static files for the page itself.

The related document tools work the same way — Markdown to HTML,HTML to Markdown andHTML to PDF all run on the device.

Common JSON errors this tool names

JSON formatting questions

How do I format JSON online?

Paste the JSON into the box, or load a .json file. The formatted output appears as you type, with 2-space, 4-space or tab indentation. Copy it or download it as a .json file. The document is parsed in this tab and never sent anywhere.

Why does it say my JSON is invalid?

The parser reports the first position it cannot read: line, column and the reason. The most common causes are a trailing comma, a comment, single-quoted strings, an unquoted key, or a control character inside a string. This tool reports those by name instead of guessing, and it never "repairs" your file.

Does it support JSON5, comments or trailing commas?

No. JSON5 is a different language. If a file needs comments or trailing commas, it is not JSON, and reformatting it as JSON would silently change data. Use a JSON5 tool for JSON5 and keep .json files strict.

What does "sort keys" do?

It rebuilds every object with its keys in alphabetical order, recursively, while leaving array order untouched — arrays are ordered data, not sets. Sorting is useful for diffing two configuration files that were written by tools with different key order.

Is the output different from the input?

Only in whitespace, key order (if you asked for sorting) and escaping (if you asked for ASCII-only output). Values are parsed by the browser and serialised back, so no number, string or boolean is changed. Duplicate keys collapse to the last value, which is how JSON.parse works.

What is the size limit?

200,000 characters per run, processed locally. There is no upload endpoint and no account, so the limit exists only to keep the page responsive.

Related tools