JSON formatter

Paste JSON to make it readable, check that it is valid, or minify it to a single line.

This free online JSON beautifier, validator and minifier works in your browser. Everything runs in your browser. What you type is not sent anywhere. All inputs and calculations run locally on your device without server uploads; details on browser processing and storage are set out in the privacy policy.

What makes JSON invalid

MistakeExampleFix
Trailing comma[1, 2, 3,]Remove the last comma
Single quotes{'a': 1}Use double quotes
Unquoted keys{a: 1}Quote every key: {"a": 1}
Comments// noteJSON has no comments; remove them
Special numbersNaN, InfinityUse null or a string

When your JSON is invalid, the message gives the line and column where the parser gave up. The real mistake is usually just before that point.

Format or minify?

Format adds line breaks and indentation so people can read the structure. Minify removes every unnecessary space, which makes API payloads and config files smaller. Both keep the data exactly the same; key order is preserved.

Worked example: Fixing a syntax error and formatting a minified API response

Suppose you copy a raw payload from a browser network log that fails to parse:

{"userId": 1042, "roles": ["admin", "qa",], 'active': true}
  • Why it fails RFC 8259 JSON validation: First, there is a trailing comma after "qa" inside the array (["admin", "qa",]). Second, 'active' is wrapped in single quotes instead of double quotes ("active").
  • After fixing those two errors and clicking Format (2 spaces):
{
  "userId": 1042,
  "roles": [
    "admin",
    "qa"
  ],
  "active": true
}

Clicking Minify compresses the valid 7-line structure down to the 46-byte wire string {"userId":1042,"roles":["admin","qa"],"active":true}.

Limits and what this tool cannot do

  • Strict RFC 8259 JSON only (does not auto-repair broken JSON or JSON5): If your input contains // comments, unquoted keys, single-quoted strings, or NaN/Infinity, standard JSON.parse() reports the exact syntax error rather than silently guessing how to rewrite your data. For JSON5 syntax, use the JSON5 Formatter.
  • 64-bit integer precision in standard JSON parsers: Notice that in JavaScript-based JSON tools, unquoted integers larger than Number.MAX_SAFE_INTEGER (9,007,199,254,740,991, such as 64-bit Twitter/Snowflake IDs) should be passed as quoted strings in APIs ("id": "1849201948291049281").
  • Duplicate object keys: If an object contains two identical keys ({"a": 1, "a": 2}), JSON.parse() retains only the last key ("a": 2).

Questions

Is my JSON uploaded?

No. It is parsed by your own browser, so API keys and private data never leave your device.

Can it handle large files?

Yes, files of tens of megabytes, limited only by your device’s memory.

Does it sort keys?

No. Keys stay in the order you wrote them.

What about very large numbers?

JSON numbers beyond about 9 quadrillion lose precision in JavaScript, as in most JSON tools. Store IDs that big as strings.

Why does JSON reject trailing commas after the last item in an object or array?

The JSON specification (RFC 8259) intentionally kept the grammar minimal so simple parsers in every programming language behave identically. Unlike JavaScript or Python source code, a comma before } or ] is a syntax error in JSON.

Does formatting or minifying JSON change the order of my object keys?

No. Standard string keys stay in the exact insertion order they appeared in your input (to sort keys alphabetically, use the JSON Sorter tool).

Is my JSON payload uploaded to a server when I validate or format it?

No. Parsing and formatting run entirely inside your browser's local JavaScript runtime.

Last reviewed .

Related converters and guides