Skip to main content

JSON Formatter

Beautify, minify and validate JSON in one click, with automatic error detection.

One line in, readable out

A minified API response, and the same data after formatting.

Input
{"id":42,"tags":["draft","zh"],"meta":{"ok":true,"score":9.5},"note":null}
Output
{
  "id": 42,
  "tags": [
    "draft",
    "zh"
  ],
  "meta": {
    "ok": true,
    "score": 9.5
  },
  "note": null
}

Notice null survives as null, not as the string "null" — if yours comes back quoted, the value was already a string upstream.

What is a JSON formatter?

JSON is the most common format for exchanging data between front and back end, but machine-generated JSON is often crammed into one unreadable line. This online JSON formatter instantly beautifies messy JSON into a clear indented structure — or minifies it to the smallest size — while validating the syntax and pinpointing errors.

How to use

  1. Paste your JSON into the input box on the left.
  2. Choose the indentation (2 spaces, 4 spaces or Tab).
  3. Click Beautify to make it readable, or Minify to collapse it to one line.
  4. The result appears on the right and can be copied in one click. If the JSON is invalid, the status bar explains why.

Common use cases

  • Inspect the structure of an API response.
  • Normalize config files to a consistent indentation style.
  • Minify JSON before shipping to reduce payload size.
  • Validate hand-written JSON before your code parses it.

Why does my pasted JSON keep failing validation?

You copy a long, minified response straight out of your browser's network tab or an API client, and it's one unreadable line. Paste it here and it's instantly indented, so a mismatched bracket or a truncated payload jumps out and the error points you to the offending line. Keep in mind this tool only formats and validates syntax — it won't fix your data or fill in missing fields. And most 'invalid JSON' isn't a bug in the parser: JSON forbids trailing commas, single quotes, and comments. Objects pasted from JavaScript or Python often include exactly those, which looks right but never parses. Strip them out and it usually validates.

How should you read the position in the error message?

Read the position, not the prose. This page returns, for several kinds of almost-JSON: a trailing comma → ✗ JSON syntax error: Expected double-quoted property name in JSON at position 7 (line 1 column 8) [L1:8]; single quotes → ✗ JSON syntax error: Expected property name or '}' in JSON at position 1 (line 1 column 2) [L1:2]; a missing closing brace → ✗ JSON syntax error: Expected ',' or '}' after property value in JSON at position 12 (line 1 column 13) [L1:13]. Note the last one: position 12 is the end of the input, because the parser only knows something is missing once it runs out of characters — the mistake is at the opening brace on the left, the report is at the far right. When the reported column is the last character of the file, look for an unclosed bracket instead of reading the line it points at.

Frequently Asked Questions

Does this tool upload my data?

No. All formatting, minifying and validation run locally in your browser with JavaScript. The JSON you paste is never sent to a server or stored.

Can it handle large JSON files?

Yes, as long as it fits in your browser memory. Files of a few MB are processed instantly; for very large files, use a desktop browser.

Why do I get a "syntax error"?

Common causes are trailing commas, unquoted keys, single quotes instead of double quotes, or comments. The error message points to the approximate location so you can fix it.

What is the difference between beautify and minify?

Beautify adds indentation and line breaks for readability and debugging; minify strips all whitespace into one line for the smallest size, ideal for transport or embedding.

Related reading

What Is JSON? A 5-Minute Guide to Structure and Common Errors →

Embed this tool

Add this tool to your own website or blog for free — just copy and paste the code below (it includes a link back to this site).