Formatters & Code

JSON Formatter

Format, validate and minify JSON in the browser. Invalid JSON is reported, and large JSON integers can lose precision in ordinary numbers.

JSON input

Formatting & key order

Pretty uses an indent of 2. Minify uses an indent of 0. Keys are not sorted.

Interactive collapsible JSON node inspector. Click triangles to expand or collapse nodes.

Enter valid JSON in the Formatter tab or click Format to generate the tree.

Semantic JSON comparison. Compares objects and arrays regardless of key order.

Convert JSON to YAML, CSV, XML, or TypeScript interfaces client-side.

Results

What the result means

Formatting parses the text as JSON and prints it again. Pretty mode indents with two spaces. Minify mode uses an indent of zero, which drops insignificant whitespace and leaves a single line. The parser does not evaluate the text as a program, so a trailing comma, a comment, or a single-quoted string is an error rather than something to repair. On failure the page shows the engine message. Keys stay in the order the parser kept, which is source order, not alphabetical order. Large JSON integers can lose precision, so numbers outside the safe range are blocked before output or comparison. The tabs let you inspect collapsible trees, compute side-by-side diffs, or convert to YAML, CSV, XML, and TypeScript interfaces.

Related tools

Guides

Advertisement

Questions

Why is trailing comma invalid?

JSON allows a comma only between values, not after the last value in an object or an array. JavaScript source sometimes accepts that extra comma, but the JSON parser does not. Comments and single quotes fail for the same reason, because they are not part of the grammar. Delete the extra comma and run it again.

Does this sort keys?

No. Keys stay in parsed order; they are not sorted. The parser remembers the order in the text, and the printer writes that same order back. Two objects that differ only by key order will still differ after formatting.

Will large numbers stay exact?

Integers that fit in an ordinary number stay exact aside from spacing. Numbers outside the safe integer range are blocked with a warning because they can lose precision. Quote identifiers as strings in the original source or use a lossless parser. Whitespace outside strings is stripped and then added back only as indentation. Characters inside strings are kept as their values rather than as the original spelling.

Need help with a tool or found a bug?

Report an issue directly to engineering. No accounts required — all client data remains private on your device.

Report an Issue →