Developer JSON Formatter

JSON Formatter

Paste raw JSON below to validate and beautify it, or minify it into a single line.

Object with 5 keys · 157 → 264 bytes

How to use this tool

The page opens with the order record from the worked example below, already beautified. Replace it with your own JSON and pick Beautify (2 spaces), Beautify (4 spaces) or Minify. The output updates as you type, and a line under the buttons says what was parsed (an object and its number of keys, or an array and its number of items) and how the size changed. If the JSON is invalid you see your browser's own parser message instead; in Chrome and Firefox it includes the line and column where parsing stopped.

Worked example: one order, three sizes

This order record, minified the way an API usually sends it, is 157 bytes:

{"id":1042,"customer":{"name":"Asha Rao","city":"Pune"},"items":[{"sku":"A1","qty":2,"price":499},{"sku":"B7","qty":1,"price":1299}],"paid":true,"note":null}

Beautified with 2 spaces it becomes 21 lines and 264 bytes; with 4 spaces, 338 bytes. The data is identical in all three. Indentation only adds whitespace between values, and spaces inside strings, like the one in "Asha Rao", are never touched. That is why minifying saves bandwidth for machines while beautifying is only for people: the 2-space version here is 68% larger for no change in content.

What else changes when JSON is re-formatted

Formatting works by parsing the text and writing it out again, so escape sequences come back in their simplest form:

  • "\u20b9499" becomes "₹499", and the surrogate pair "\ud83d\ude00" becomes "😀", the emoji itself. The value is the same; only the spelling changed.
  • "a\/b" becomes "a/b". The escaped slash is legal JSON but never necessary.
  • Tabs and control characters stay escaped (\t, \u0007), because a raw one inside a string would make the JSON invalid.

If a file has to stay byte-for-byte identical, for example because something checks its hash or signature, compare before replacing it with formatted output. For what each parser error means, see the common JSON errors guide.

Frequently Asked Questions

Can formatting change my data?

In two cases, both caused by the standard JSON.parse the formatter uses. Integers longer than about 15 digits lose precision: {"id": 12345678901234567890} comes back as 12345678901234567000, so quote long IDs as strings. And if an object repeats a key, only the last value survives: {"a": 1, "a": 2} becomes {"a": 2}. Numbers such as 1.10 are also rewritten in their shortest form, 1.1.

Can it format JSON with comments or trailing commas (JSONC or JSON5)?

No. It uses the browser's strict JSON parser, so a // comment or a comma before a closing bracket is reported as an error. That is deliberate: files such as tsconfig.json or VS Code settings allow comments, but an API or JSON.parse in your own code won't. Remove the comments and trailing commas first, or format the file with an editor that understands JSONC.

Is there a size limit?

There is no fixed limit, but the text is parsed in the page on every keystroke, so multi-megabyte payloads make typing sluggish. For large exports, paste the whole thing once rather than editing it here, or convert it with a file tool such as the JSON to Excel converter, which processes big files in a background worker.

Related Tools

Related Blog Posts