Skip to content

What is a JSON Formatter?

A JSON formatter takes raw JSON text and either beautifies it — adding consistent indentation and line breaks — or minifies it by stripping all unnecessary whitespace. Both operations parse and re-serialize the input via JSON.parse and JSON.stringify, which also validates that your JSON is syntactically correct. Everything runs in your browser — no data is sent to a server.

How to Use

  1. Paste your JSON into the input panel, drop a .json file on it, or click Sample.
  2. The output beautifies as you type. Choose Pretty for indented output, Tree to collapse and explore nested objects, or Minify for a compact single-line string.
  3. Pick 2 spaces, 4 spaces, or tabs, and optionally sort keys alphabetically.
  4. If the input is invalid, the error shows the parse failure with its line and column.
  5. Copy or download the result, or send it straight to the JSON → YAML converter, Diff Checker, Base64 encoder, or Hash generator.

Common JSON Errors

  • Trailing commas — { "a": 1, } is invalid. Remove the comma after the last item in objects and arrays.
  • Single quotes — JSON requires double quotes. { 'key': 'value' } will fail.
  • Unquoted keys — { key: "value" } is valid JavaScript but not valid JSON. All keys must be quoted strings.
  • Comments — JSON has no comment syntax. Remove any // or /* */ blocks before formatting.
  • Missing commas — Every element except the last in an object or array must be followed by a comma.

FAQs

What is the difference between beautify and minify?

Beautify adds indentation and newlines so the structure is easy to read. Minify removes all unnecessary whitespace to shrink file size — useful before sending JSON over a network or storing it in a database.

Does formatting change my data?

No. Formatting only changes whitespace. Keys, values, types, and order are preserved exactly. The one exception is duplicate keys in the same object — JSON.parse keeps only the last occurrence.

What is the maximum file size this tool can handle?

There is no hard limit enforced by the tool. Practical limits depend on your browser's available memory. For very large files (tens of MB), consider a local CLI tool like jq instead.