JSON Formatter

Format, validate, and minify JSON — pretty-print or compress in one click.

Format

Paste raw JSON to format or minify.

Scroll inside the box for long output; the copy button stays in view.

Formula used

Pretty (2-space indent):
  output = JSON.stringify(parsed, null, 2)

Minify (no whitespace):
  output = JSON.stringify(parsed)

Both first run JSON.parse(input); on failure the input is reported as invalid.

Worked example

Input (minified): {"name":"Ada","active":true,"roles":["admin","dev"]}

Pretty output:

{
  "name": "Ada",
  "active": true,
  "roles": [
    "admin",
    "dev"
  ]
}

Well-formatted JSON is not a cosmetic nicety — it is a debugging and communication tool. When an API returns a single dense line of nested objects, the human eye cannot trace structure, spot a missing comma, or tell which value belongs to which key. Pretty-printing with consistent two-space indentation turns that opaque string into something you can actually read, review in a pull request diff, or paste into a ticket for a teammate. In version control especially, compact JSON produces noisy diffs where a one-field change touches an entire line, whereas indented JSON localizes the edit to the lines that truly changed. The formatter also serves as a gatekeeper: if the input fails to parse, the tool reports the error instead of guessing, so a clean output is a reliable signal that your data is syntactically valid before it ever reaches production code.

The most common real-world use is untangling a response from a server. You copy a raw payload from a network inspector, a curl output, or a log file, paste it in, and immediately see the shape of the data — which keys exist, how arrays nest, where a value you expected is missing. That single step saves enormous time compared to mentally parsing a wall of text. The same applies to configuration files like package.json or tsconfig.json that have drifted into inconsistent formatting: normalizing them makes reviews faster and prevents the subtle bugs that arise when a teammate edits the wrong field because indentation misled them. When you are building a mock or writing documentation, pretty-printed samples are also far easier for other developers to copy correctly than minified ones, which reduces the chance of transcription errors creeping into downstream work. This tool does two opposite jobs, and choosing the right one matters. Pretty mode adds two spaces of indentation per level so humans can read and edit the result — ideal for local files, documentation, and anything going through code review. Minify mode strips every unnecessary space and newline, producing the most compact representation possible, which is what you want when sending JSON over a network, storing it in a cache, or embedding it where size directly affects cost or latency. A useful habit is to keep your source and config files pretty for people, then minify at the boundary — in your build step or your server responses — so machines get the small version and humans keep the readable one. Because formatting only ever changes whitespace and never the data itself, you can switch between the two modes as often as you like with zero risk of altering a value, a key, or an array's order. Beyond cosmetics, running text through a formatter surfaces real errors before they cause outages. The parser will reject trailing commas, single quotes, unquoted keys, and comments — all of which are legal in JavaScript object literals but illegal in strict JSON, and all of which quietly break a backend that expects valid JSON. It also catches mismatched or missing braces and brackets, which are easy to introduce when hand-editing a large payload. Catching these locally, in a fraction of a second, is far cheaper than discovering them when a request 500s in production or a config file fails to load on a server. Treat a successful format as a free validation pass: if the tool outputs your data cleanly, you have strong evidence the structure is sound; if it errors, you have found a defect at the cheapest possible moment, with the exact location usually spelled out for you to fix. Because the formatting and validation happen entirely in your browser, nothing you paste is uploaded, stored, or logged on a server. That matters more than it sounds: JSON payloads frequently contain tokens, user records, internal field names, and other sensitive material you would never want to send to a third-party website. Processing locally means you can safely format production-shaped data on a laptop without it ever leaving the machine. It also means the tool works offline and responds instantly regardless of network conditions, which is a real advantage when you are working in a locked-down or air-gapped environment. The same principle applies to the related developer tools on this site — they are designed to be utilities you can trust with real data, not conveniences that quietly exfiltrate it to some remote service you cannot see.

Consistent JSON formatting is also a team discipline, not just a personal convenience. When every developer on a project formats config and fixture files the same way, code reviews become faster and merge conflicts shrink, because the diffs reflect real changes rather than whitespace churn. Many teams codify this with a formatter or a pre-commit hook so files are normalized automatically before they are committed, removing the temptation to "fix formatting later" that so often never happens. The same consistency helps when sharing samples in documentation, tickets, or chat: a uniform, readable shape lets a teammate trust and reuse the snippet immediately instead of reformatting it themselves first.

Frequently asked questions

Is this a JSON validator?

Yes. If the input cannot be parsed, the tool reports the error and shows nothing, so a successful output means the JSON is valid.

What indent does pretty mode use?

Two spaces per level. That is the most common convention for readable JSON and works well in version control diffs.

Does formatting change my data?

No. Formatting and minifying only change whitespace. Keys, values, ordering, and types are preserved exactly.

Can I minify to shrink a payload?

Yes. Minify removes all unnecessary whitespace, which reduces size when you send JSON over a network or store it.