JSON Formatter and Beautifier

Format and pretty-print JSON with 2 spaces, 4 spaces or tabs, optionally sort keys, and get exact line and column for syntax errors. Runs in your browser.

Output

Runs entirely in your browser. Your data is never uploaded.

Related Tools

View All

What is JSON Formatter?

The JSON Formatter re-indents minified or messy JSON so it is easy to read. It uses a strict RFC 8259 parser, so it also tells you exactly where invalid JSON breaks (line, column and a pointer to the character). Large integers such as 64-bit IDs are kept exactly as written instead of being rounded.

How to use JSON Formatter

  1. Paste your JSON into the JSON input box (or click Load sample).
  2. Choose the Indentation: 2 spaces, 4 spaces or Tab.
  3. Tick Sort keys alphabetically if you want object keys ordered.
  4. Click Format (the output also updates automatically while you type).
  5. Copy the result with Copy or save it with Download.

Example

Input
{"id":12345678901234567890,"a":[1,{"b":null}]}
Output
{
  "id": 12345678901234567890,
  "a": [
    1,
    {
      "b": null
    }
  ]
}

2-space indentation; the 20-digit ID is preserved exactly.

When to use JSON Formatter

Use it to read API responses, config files or logs, to review diffs with stable key order, or to find the exact location of a JSON syntax error. It does not accept JSON5 or JSONC (comments, trailing commas, unquoted keys) – those are reported as errors. To check data against rules (types, required fields) use the JSON Schema Validator instead.

How JSON Formatter works

The input is parsed by a hand-written strict JSON parser that builds a tree while tracking positions. Numbers are stored as their original text, so 12345678901234567890 or 1.50e+10 are printed unchanged, unlike JSON.parse, which converts to 64-bit floats. The tree is then printed with the chosen indent; strings are re-escaped in canonical form (for example \u00e9 becomes é). When sorting is on, keys are ordered by Unicode code point at every level. On a syntax error, the parser stops at the first offending character and reports a specific reason such as a trailing comma, single quotes, a comment or a missing comma.

Common Use Cases

  • Pretty-printing a minified API response before debugging
  • Normalising config files with sorted keys so diffs are smaller
  • Finding the line of a missing comma in a large JSON file
  • Inspecting JSON that contains 64-bit IDs without precision loss

Security Note

Everything runs locally in your browser; the code you paste is not uploaded.

FAQs

Why does my JSON with comments fail?

Standard JSON (RFC 8259) does not allow comments or trailing commas. The formatter reports them with their position so you can remove them.

Are big numbers changed?

No. Numbers are copied as written, so integers larger than 2^53 keep every digit.

What happens with duplicate keys?

Both entries are kept in the output in their original order. The JSON Validator lists duplicates as warnings.

Is the key order changed?

Only if you enable Sort keys alphabetically; otherwise the original order is kept.

Good next steps

Explore more categories