Skip to content

JSON FormatterBeta

Pretty-print, minify, or validate JSON with exact line and column on syntax errors. Sort keys, escape Unicode. Runs fully in your browser — nothing is uploaded.

0 characters · 0 lines
Mode

0 characters · 0 lines

How to use it

Paste your JSON into the input box and the result appears. Choose “Format” to apply indentation (2 spaces, 4 spaces, or a tab) so the structure is easy to scan, or “Minify” to strip all the unnecessary whitespace and line breaks and shrink the size. “Validate” checks the syntax without changing anything. Turn on “Sort keys” to recursively sort every object’s keys in alphabetical (strictly, Unicode code unit) order, and “Escape non-ASCII” to turn characters like emoji or non-Latin text into \uXXXX escapes. If the JSON you pasted isn’t valid, you’ll see an error instead of a result, with the exact line and column of the problem and a small snippet of the surrounding text.

Format, minify, and validate are three different jobs

All three modes work on the same JSON, but for different purposes. “Format” (pretty-printing) adds indentation and line breaks to make the document easy for a person to read; “Minify” does the opposite, stripping that whitespace to shrink the file size. Neither one changes the actual values — except for the cases described in “Big numbers can lose precision” below (an out-of-range number becoming null, a duplicate key keeping only its last value), and one more: a -0 in the input becomes 0 in the output. “Validate” isn’t about displaying anything — it just checks whether the JSON is syntactically correct. All three go through the same parser internally, so a successful format or minify is itself proof that the JSON was valid.

Common JSON syntax mistakes

JSON’s grammar is simple, but it’s strict about small things. The usual culprits are a trailing comma left after the last item in an array or object ([1, 2, 3,]), strings or keys wrapped in single quotes instead of double quotes (JSON only allows double quotes), object keys without quotes at all ({name: "a"}), // or /* */ comments left in from editing, a leading zero on a number (01), and mistaking a JavaScript object literal — which can have undefined values or trailing commas — for JSON. Turning on “Allow comments & trailing commas” cleans up comments and trailing commas automatically before parsing, but other syntax problems like single-quoted strings or unquoted keys still need to be fixed by hand.

JSON vs. JSON5 vs. JSONC

“JSON” is the strict standard defined by RFC 8259 and ECMA-404: no comments, no trailing commas, and strings must use double quotes. “JSON5” and “JSONC” (JSON with Comments, familiar from editor config files like VS Code’s settings.json) are more permissive dialects meant to be friendlier to write by hand, allowing comments, trailing commas, and sometimes unquoted keys. This tool checks standard JSON by default, but turning on “Allow comments & trailing commas” lets it accept the most common JSON5/JSONC habits — comments and trailing commas — by stripping them before parsing. That option is built to leave // and commas inside string values alone.

Big numbers can lose precision

JavaScript has a single number type, an IEEE 754 double-precision float, which can only represent integers exactly up to 2^53 - 1 (9007199254740991, 16 digits). If a JSON document contains a longer integer literal — a 64-bit snowflake ID used by some systems, for example — JSON.parse will round it to the nearest value it can represent, silently changing the last few digits with no error raised. This tool scans the raw text for integer literals of 16 digits or more before parsing and shows a warning, without altering the value (rewriting it, say to a string, would change the shape of your document). If you need the exact value preserved, store it as a string at the source, or use a tool built specifically to handle big integers.

Two other cases also change values without raising an error, and the tool warns about both. A number too large for a double at all, such as 1e400, is read as Infinity and becomes null in the output. And if the same key appears more than once in one object, JSON.parse keeps only the last value and silently drops the earlier ones.

Privacy

The JSON you paste is processed entirely in this browser tab and is never stored or transmitted anywhere. Closing the page discards it.

Sources

Frequently asked questions

Does this validate against a JSON Schema, or does it only check syntax?

It only checks syntax (RFC 8259 / ECMA-404) — that brackets and braces match, strings are double-quoted, and commas are placed correctly, among other basic JSON rules. It does not validate against a JSON Schema, so it won't catch a missing required field or a value with the wrong type. For that you'd need a tool built for that specific schema.

What exactly does "Allow comments & trailing commas" do, and is it safe to leave on?

When it's on, the tool strips `//` and `/* */` comments and trailing commas after the last item in an array or object before parsing — handy for JSON5/JSONC-style input. It leaves `//` and commas inside strings untouched. Leaving it on all the time means input with comments, which is technically invalid under strict JSON (RFC 8259), will still be accepted, so turn it off when you specifically want to check standard JSON compliance.

Why do I see a warning about numbers losing precision, and what should I do about it?

JavaScript has one number type, an IEEE 754 double, which can only represent integers exactly up to 2^53 - 1 (9007199254740991, 16 digits). If your JSON contains a longer integer literal — a 64-bit ID from some system, for example — `JSON.parse` can silently round it to the nearest representable value, changing the last few digits without raising an error. This tool scans the raw text for integer literals of 16 digits or more before parsing and just warns you; it doesn't rewrite the value (doing so would change the document's structure). If you need the exact value, keep it as a string at the source, or use a tool designed to handle big integers safely.

Can it handle large JSON files? What's the size limit?

Yes, up to about 10MB directly in this browser tab. Above that it shows a message instead of trying, since parsing and formatting a very large JSON document on the main thread could freeze the tab for a moment.

Is the JSON I paste sent anywhere?

No. Everything happens locally in this browser tab, and nothing is sent to a server. Closing the page discards it.