JSON Formatter & Validator

Paste JSON to format it with 2-space indentation, or minify it — invalid JSON shows a clear error.

Copied ✓

What it does

Paste any JSON into the box and choose Format to pretty-print it with two-space indentation, or Minify to strip all whitespace and produce the smallest possible string. If the input is not valid JSON, a clear error message appears so you know exactly what went wrong. Everything runs in your browser — nothing you type is sent anywhere. New to JSON itself, rather than just formatting it? Our plain-language guide to JSON for non-developers explains the format from scratch.

Why formatting matters

Readability. Machine-generated JSON often arrives as one long line. Formatting expands it into a human-readable tree where nesting is immediately visible. This is invaluable when reading API responses, config files, or debugging output.

Wire size. The opposite is also true: before sending JSON over the network or storing it in a database, minifying it removes every whitespace character that a machine does not need. A deeply nested document can shrink by 20–30% after minification.

What “valid JSON” means

JSON has a strict grammar defined by RFC 8259. The most common mistakes that make JSON invalid are:

  • Trailing commas{"a":1,} is invalid; the comma after the last item is not allowed.
  • Single quotes — strings must use double quotes. {'a':1} is not valid JSON (though it is valid JavaScript).
  • Unquoted keys — every key must be a quoted string. {a:1} is invalid.
  • Comments — JSON has no comment syntax; // comment or /* */ cause a parse error.
  • Undefined, NaN, Infinity — these JavaScript values have no JSON representation; only numbers, strings, booleans, null, arrays, and objects are allowed.

Worked example

Formatting {"a":1} with two-space indentation produces:

{
  "a": 1
}

Minifying that result back produces {"a":1}.

Worked example — nested data

Real API responses usually nest objects inside each other. Formatting {"user":{"name":"Alice","age":30},"active":true} produces:

{
  "user": {
    "name": "Alice",
    "age": 30
  },
  "active": true
}

Each level of nesting adds two more spaces of indentation, so the structure is visible at a glance without counting braces.

Worked example — catching an error

Input {a: 1} fails to parse, because a is not wrapped in quotes. The tool surfaces the parser's own error message rather than guessing what you meant, so you can find the exact character it stopped at and fix it.

Edge cases and limitations

  • Very large integers can lose precision. JSON numbers have no size limit, but this tool parses with the browser's own JSON parser, which stores every number as a 64-bit floating-point value. Integers larger than 253 (9,007,199,254,740,992) can't be represented exactly, so a large ID such as a database snowflake ID or a Discord/X user ID may come back off by one or more after formatting. If your JSON carries IDs like this, keep them as strings in the source rather than raw numbers.
  • Duplicate keys keep only the last value. {"a":1,"a":2} is technically parseable, but the parser silently keeps only "a":2 — the first is discarded without a warning.
  • Numeric-looking keys get reordered. JavaScript objects always list integer-like string keys in ascending numeric order ahead of any other keys, regardless of the order they appeared in your source — {"b":1,"2":2,"a":3} formats with "2" moved to the front. This is standard JavaScript object behaviour, not a bug in the tool.
  • No schema or type checking. The tool confirms your JSON is syntactically valid; it doesn't check it against a schema, so a well-formed document with the wrong shape — a string where a number was expected — still passes.

Frequently asked

Does this tool modify my data?

No. Formatting and minifying only change whitespace. The values, keys, and structure of the JSON are identical before and after.

What indentation style does it use?

Two spaces per level, which is the most widely used style and matches the default for JSON.stringify(value, null, 2) in JavaScript.

Will it handle large JSON files?

Yes, up to the limits of your browser's memory. For files of tens of megabytes the browser may pause briefly, but there is no server round-trip to worry about.

Why does it show an error for my JSON?

The error message comes directly from the browser's JSON parser and identifies what it found unexpected. The most common causes are the ones listed above: trailing commas, single quotes, or unquoted keys. Fixing those usually resolves the error immediately.

Will large numbers in my JSON stay accurate?

Not always. IDs and counters larger than 253 can lose precision because the parser stores every number as a 64-bit float. If accuracy matters for a specific large number, check it against the original source rather than trusting the formatted output.

Does the order of keys in an object matter?

JSON objects are technically unordered, but in practice most parsers preserve the order keys were written — except integer-like keys, which JavaScript always sorts numerically ahead of everything else. Don't rely on key order to carry meaning in your data.

Can I format JSON that has comments in it?

No — standard JSON has no comment syntax. Config files that look like JSON but allow // comments (such as tsconfig.json) are actually JSONC or JSON5, a related but different format this tool doesn't parse. Strip the comments first, or use a tool built for that variant.