Skip to content
Browser tool Runs locally

JSON Formatter & Beautifier

Paste JSON to format, beautify, validate, or minify. Runs locally in your browser.

Input JSON
0 chars
Formatted output
Formatted JSON will appear here.

What is a JSON formatter?

A JSON formatter takes compact or messy JSON and rewrites it with consistent indentation so it is easy to read.

How to use this tool

  1. Paste or type JSON in the input panel.
  2. Click Format JSON - or press ⌘/Ctrl + Enter.
  3. Use Validate to check syntax, or Minify for compact output.
  4. Copy or download the result.

A practical formatting example

A minified API response like {"user":{"id":42,"roles":["admin","editor"]}} is technically valid but hard to scan. Formatted, each key lands on its own line and nested structures indent one level further - the roles array visibly sits inside user instead of being buried in a single unbroken line. Nothing about the data changes; only its layout does.

Why consistent indentation matters

Consistent indentation makes nesting depth visible at a glance, so you can tell which brace or bracket closes which object without counting characters. That matters most in two situations: reviewing a diff of a config file, where inconsistent formatting creates noise unrelated to the actual change, and debugging a deeply nested API response, where matching an unexpected value back to its parent object is much harder in a single dense line than in an indented tree.

Common formatting mistakes

  • Trailing commas - a comma after the last item in an object or array is valid in JavaScript object literals but not in JSON.
  • Single quotes - JSON requires double quotes around strings and keys; single quotes will fail to parse.
  • Comments - JSON has no comment syntax, so // or /* */ notes copied from JavaScript or a config file must be removed first.
  • Unquoted keys - object keys must be quoted strings, even when they look like valid identifiers.

Formatter vs. validator

A formatter's job is presentation: given JSON that already parses, it rewrites the whitespace for readability. A validator's job is correctness: it checks whether the input parses at all and tells you exactly where it fails if it doesn't. This tool leads with formatting because most JSON people paste in is already valid - but when it isn't, use Validate first to locate the syntax error before trying to format it.

Frequently asked questions

Does formatting fix invalid JSON for me?
No. A formatter can only re-indent JSON that already parses successfully. If the input has a syntax error - a trailing comma, a missing quote - formatting fails and points you to the problem instead of guessing what you meant.
What's the difference between formatting and validating?
Formatting rewrites already-valid JSON with consistent indentation so it's easier to read. Validating only checks whether the JSON is syntactically correct and reports where it isn't - it never rewrites anything. This tool does both, but they're separate steps.
Why does my formatted JSON look different from what I pasted?
Formatting only changes whitespace - indentation, line breaks, and spacing around colons and commas. Keys, values, and their order are untouched, so the data itself never changes, only how it's laid out on the page.
Can 2-space and 4-space indentation both be valid?
Yes. JSON itself has no opinion on indentation width - 2 spaces, 4 spaces, and tabs are all equally valid JSON. The choice is purely a readability preference, often set by a team's style guide or editor config.
Why does formatting fail on JSON that looks fine to me?
The most common causes are a trailing comma after the last item in an object or array, single quotes instead of double quotes around strings and keys, or an inline comment - all of which are common in JavaScript object literals but are not legal JSON.

Related tools