JSON Formatter & Beautifier

Paste raw or minified JSON to pretty-print it with the indentation you want. Invalid input is pinpointed by line and column with a hint on how to fix it.

Loading tool…

About the JSON Formatter

The formatter parses your input with a strict RFC 8259 parser and re-serializes it with JSON.stringify, so the output is always valid JSON with consistent indentation: 2 spaces (the most common style in JavaScript projects), 4 spaces (Python's json.dumps(indent=4) default), a tab, or fully minified. Formatting never changes values — strings, numbers, booleans and null come out exactly as parsed.

When parsing fails, the error names the exact position and the usual cause: a trailing comma before }, single-quoted strings, unquoted property names, comments, undefined or NaN, or Python literals such as True and None. These are the mistakes that appear when JSON is written by hand or copied from JavaScript source.

Sort keys A→Z orders object keys recursively by code point, which makes two API responses or config files easy to compare in a diff. Array order is never changed. Two details worth knowing: duplicate keys are collapsed to the last value (the status line warns you), and integers larger than 253 − 1 (9007199254740991) lose precision in JavaScript — the tool flags them so you do not silently corrupt 64-bit IDs. Everything runs locally in your browser; nothing is uploaded.

How to use it

  1. Paste JSON into the input box, or open a .json file.
  2. Choose 2 spaces, 4 spaces, Tab or Minify.
  3. Tick Sort keys A→Z if you want a stable key order.
  4. Fix any error shown at the reported line and column.
  5. Copy the result or download it as data.json.

Frequently asked questions

Why does my JSON fail with a trailing comma?
The JSON standard (RFC 8259 / ECMA-404) does not allow a comma after the last item in an object or array. JavaScript object literals and JSON5 do, which is why copied code often breaks. Remove the comma before the closing } or ].
Can I format JSON with comments?
No. Comments are not part of JSON, so // and /* */ are reported as errors. Files such as tsconfig.json use the JSONC dialect; strip the comments first or use an editor that understands JSONC.
Does sorting keys change the meaning of my data?
No. JSON objects are unordered by definition, so reordering keys keeps the data equivalent. Arrays are ordered and are left untouched.
Why did a large number change after formatting?
JavaScript numbers are 64-bit floats, so integers above 9007199254740991 are rounded when parsed. The tool warns when this happens. Transmit such IDs as strings.

Related tools