Developer / Free browser tool
JSON Formatter and Validator
Paste JSON to indent it, compress it, sort its keys or find out why it will not parse. The output is built with JSON.parse and JSON.stringify, so it matches what a JavaScript runtime sees.
No account or install. Tool input is processed on your device.
Parsed with JSON.parse and written with JSON.stringify, so comments, duplicate keys and number spellings such as 1.0 do not survive. Integers above 253 − 1 are rounded by JavaScript before formatting.
Nothing pasted yet.
Nothing formatted yet.
That is not valid JSON.
This input contains integers that JavaScript cannot represent exactly.
Input 0 B · output 0 B · nothing parsed.
About this tool
Paste JSON to validate, format, minify or sort it. The tool parses input with JSON.parse and writes output with JSON.stringify. Invalid JSON is reported rather than repaired automatically, and the last valid output remains available while you correct the input.
When the browser parser reports an error offset, the tool converts it to a line and column and shows the relevant source line with a caret. The exact error text varies between JavaScript engines.
Numbers are parsed as IEEE 754 doubles, so integers beyond the safe-integer range can lose digits. Integer-like object keys also follow JavaScript's property ordering rules. Formatting cannot preserve digits or key positions that the parser has already changed.
Why the output is not byte-identical
Formatting is a round trip through a data structure, not a text transformation. Comments are not valid JSON and are rejected rather than stripped. Duplicate keys collapse to the last value, because an object can only hold one. 1.0 becomes 1 and 1e3 becomes 1000. Those changes are correct for the data and surprising for the file, which is why the status line reports the parsed size rather than claiming the text is unchanged.
Sorting keys and reading the result
Sort uses a plain code-unit comparison, the same order as < on strings, so uppercase keys come before lowercase and item10 comes before item2. Sorting is recursive and applies to every object at every depth. Arrays keep their order, because an array index carries meaning. Keys such as "10" are moved to the front by the language itself before sorting runs, and no formatter can undo that.
The status line counts bytes, not characters. A string with 40 accented letters is longer in UTF-8 than its character count suggests, and the byte count is the number that matters when a payload has to fit a size limit.
JSON.parse turns every number into a double, so an integer with more than 15 significant digits is rounded before the formatter sees it. The page warns when the input looks like it contains one, but it cannot recover the original digits.
How it works
Paste or load JSON
The sample is a small order object with nesting, an array, booleans and null. The preview updates on a short delay as you type.
Choose the shape
Format indents with 2 spaces, 4 spaces or a tab. Minify writes the compact form. Sort keys A–Z reorders objects without touching arrays.
Copy or download
Copy puts the output on the clipboard; Download saves it as formatted.json. The status line reports input and output bytes, key count and nesting depth.
Common questions
Why does the formatter reject a trailing comma?
JSON does not allow trailing commas. JavaScript object literals do, which is why the habit carries over from code. The parser is JSON.parse, so the strict rule applies; remove the comma and the error moves to the next problem.
What happens to duplicate keys?
The last value wins. JSON.parse builds an object, and an object has one value per key, so earlier duplicates are gone before the formatter sees them. The page cannot warn about this because the information is already lost.
Can it handle a 10 MB file?
It can, slowly. The whole document is parsed into memory and re-serialized, which takes roughly twice the file size in RAM. Very large inputs make the tab unresponsive; there is no streaming mode.
Does sorting keys change the data?
No. Object key order is not semantic in JSON, though some tools display it. Sorting changes the text and nothing else. Arrays are never reordered.
Is the JSON sent anywhere?
No. Parsing, formatting and the download all happen in the tab, and no request from this page carries the input.
Related tools
Timestamp converter
Paste an epoch value and read it six ways, or turn a date into seconds and milliseconds. The unit is detected, but never guessed silently.
Test data generator
Pick the columns, choose a seed and a format, and get a table of fictional people to paste into a fixture. The seed is the whole state: same seed, same output.
Base64 converter
Two directions, converted as you type. Invalid characters, impossible lengths and bytes that are not valid UTF-8 are reported rather than turned into plausible-looking rubbish.