JSON Formatter and Validator
Paste JSON, choose 2 spaces, 4 spaces, or tabs, sort keys, then Format or Minify. Errors show line and column, and the last valid result stays visible.
Runs in your browser. Nothing you enter is uploaded.
How to use the JSON formatter & validator
- Paste your JSON into the JSON textarea.
- Choose 2 spaces, 4 spaces, or Tabs in the Indent select, and check Sort keys if you want alphabetical keys.
- Click Format to pretty-print, or click Minify to produce compact JSON.
- Check the error message or stats, then use Copy or Download .json for the Result.
What does a JSON formatter change?
A JSON formatter rewrites valid JSON with consistent indentation and spacing. It does not change the data. For example, {"b":1,"a":[1,2]} can format to a two-space result with "b": 1 and an array containing 1 and 2. The tool uses 2 spaces, 4 spaces, or tabs, and can sort keys recursively.
How does key sorting work?
Sort keys alphabetically inside every object, not only at the top level. For {"z":{"y":1,"x":2},"a":0}, sorting produces "a": 0 first and "z" after it. Inside "z", "x": 2 comes before "y": 1. Arrays keep their original item order, so sorting does not reorder list values.
What does minify remove?
Minify removes indentation and extra whitespace while keeping the JSON valid. For example, a formatted object with "a" : [1, 2] and "b": "x y" becomes {"a":[1,2],"b":"x y"}. Spaces inside string values remain, because they are part of the data. The output is useful for compact files or API payloads.
Frequently asked questions
Does a JSON formatter change the data?
No. It only changes whitespace, indentation, and key order when sorting is enabled. Values, array order, and types stay the same. For example, {"b":1,"a":[1,2]} formatted with 2 spaces still has the same key names, numbers, and array items.
What does line and column mean in a JSON error?
The tool points to the first place parsing fails. For input [1, 2, it reports Line 1, column 6, which is the end of the text. An empty input reports Input is empty. The last valid result remains in the Result box while you fix the source.
Can this JSON validator check Unicode?
Yes. Non-ASCII characters are kept as-is, not converted to \u escapes. For example, {"e":"é✓"} formats with the visible "é✓" string. This is useful when debugging logs, API responses, or files that contain accents, symbols, or emoji.
What is the difference between Format and Minify?
Format adds indentation using the chosen Indent setting: 2 spaces, 4 spaces, or Tabs. Minify removes indentation and extra whitespace. For the example with "a" : [1, 2] and "b": "x y", minify gives {"a":[1,2],"b":"x y"} while preserving spaces inside the string value.
How does the tool count keys and depth?
The stats line shows the number of object keys and nesting depth. For {"a":{"b":[1,{"c":2}]}}, it reports 3 keys · depth 4. The three keys are a, b, and c. A plain value such as 42 reports 0 keys · depth 0.
Can I download the result?
Yes. Click Download .json to save the current Result text as formatted.json. Copy puts the same text in the clipboard. If the Result box is empty, Download does nothing.