JSON Formatter

Paste compact or unevenly indented JSON into the input box and press Format JSON to get clean 2-space or 4-space indentation, or press Minify JSON to squeeze it onto one line — invalid input returns a pointed error message instead of output.

Result will appear here.
Ad space — place a responsive AdSense unit here after approval.

JSON Formatter online

Format and beautify JSON with the indentation you choose, or minify it back to one line — for API responses, configuration files and debugging payloads, with the parser behaviours that can quietly change your data.

Quick answer: Paste minified or unevenly indented JSON and run the formatter to get readable indentation.

How it works

The tool parses your text with JSON.parse and re-serialises it with an indent control: the Indent dropdown offers 2 or 4 spaces for the Format button, while the Minify button formats with indent 0, stripping all unnecessary whitespace. If parsing fails you get Invalid JSON: followed by the parser message, plus a line and column hint (for example, line 1, column 9) whenever the error includes a character position.

Worked example

Pasting {"name":"Alice","age":30} and choosing indent 2 returns the same data expanded over four lines with two-space nesting — "name" and "age" each on their own indented line inside the braces. Pressing Minify on that expanded text collapses it back to the original single line {"name":"Alice","age":30}. Pasting broken input such as {"name":} instead produces Invalid JSON: Unexpected token ... with the position where the parser stopped.

Options

  • Indent 2: compact readable output, good for logs and chat snippets.
  • Indent 4: roomier nesting, easier to scan in deeply nested API responses.
  • Minify JSON: single-line output for pasting into URLs, config fields, or size-sensitive payloads.

Practical tips

  • Read the line and column. A position like line 3, column 14 points at the exact comma, quote, or bracket to fix.
  • Format before debugging. Minified API responses hide duplicate keys and misplaced brackets that indentation exposes.
  • Minify before sending. Whitespace from 4-space output adds bytes to every request body.
  • Check quotes first. Single-quoted keys and trailing commas are the most common failures — strict JSON rejects both.

Edge cases and limitations

  • Large integers lose precision. Formatting parses the JSON and re-prints it, and the parser stores numbers as double-precision floats. Integers beyond 2^53 − 1 (9,007,199,254,740,991, JavaScript's MAX_SAFE_INTEGER) cannot be represented exactly: paste 9007199254740993 and it comes back as 9007199254740992. If your JSON carries 64-bit IDs, keep them in quotes — as strings they survive untouched.
  • Duplicate keys collapse. {"a": 1, "a": 2} is syntactically valid, and a parser keeps the last value. Re-printing therefore drops the first "a" entirely — a formatter is the wrong place to discover your source had duplicates.
  • Key order is mostly preserved — with one exception: keys that look like integers ("2", "10") are reordered numerically ahead of string keys by JavaScript object rules. If key order is contractual, check numeric-like keys after formatting.
  • Comments and trailing commas are not JSON. They are the two most common reasons real-world "JSON" fails to format. Remove them (or switch to JSONC/JSON5 tooling) and the same payload usually parses cleanly.

Privacy and browser processing

Your JSON is parsed and formatted locally in your browser and is never uploaded — safe for payloads containing tokens or personal data.

Frequently asked questions

What is the difference between Format and Minify here?

Format re-prints parsed JSON with 2-space or 4-space indentation across many lines; Minify re-prints it with indent 0, so data stays on one line with no extra spaces.

Which indentation should I choose?

Use 2 for short snippets and log output, and 4 for deeply nested responses where each level needs visual separation. The parsed data is identical either way.

What happens when my JSON is invalid?

You get an Invalid JSON: message with the parser reason, and a line and column number when the error reports a character position — for example, a missing value in {"name":} flags line 1 near column 9.

Can I convert YAML or XML with this page?

No. This page only parses and re-prints JSON. For cross-format work, use the related converters such as JSON to YAML, YAML to JSON, JSON to XML, or XML to JSON.

Related tools

Ad space