utilduck
Home · Developer · JSON Formatter

JSON Formatter

Paste your JSON, then Beautify, Minify or Validate it with one click.

About JSON formatting

JSON (JavaScript Object Notation) is the most common data interchange format on the web. Raw JSON from APIs is often minified — all on one line with no spaces — which is hard to read. Beautifying adds consistent indentation so you can easily scan its structure.

Minifying removes all unnecessary whitespace, reducing file size for transmission. Validation checks that the text is syntactically correct JSON: proper bracket matching, quoted keys, comma placement and value types.

How do I beautify or minify JSON?

To beautify JSON, parse the text into a data structure and re-serialize it with consistent line breaks and indentation (commonly 2 spaces); to minify, re-serialize the same structure with no extra whitespace at all. Example: {"a":1,"b":2} beautifies to a 4-line block with 2-space indents, and minifies right back to {"a":1,"b":2}.

Steps to beautify, minify, and validate JSON

  1. Paste the raw JSON text into the input box.
  2. To beautify, the tool parses the text into an object/array structure, then writes it back out with 2-space indentation and one line break per key or array item.
  3. To minify, the tool parses the same structure but writes it back with no line breaks or extra spaces, leaving only the characters required for valid syntax.
  4. To validate, the tool attempts to parse the text without reformatting it; a successful parse means the JSON is syntactically valid.
  5. If parsing fails at any step, the exact reason (unexpected token, missing comma, unmatched bracket) is surfaced so you can locate and fix the error.

Beautify vs. minify

Beautify: parse(text) -> stringify(value, indent=2) | Minify: parse(text) -> stringify(value, indent=0)
  • parse = converts JSON text into an in-memory object, array, string, number, boolean, or null
  • stringify = converts that structure back into JSON text, with or without indentation

Example beautify and minify results

InputBeautified (2-space indent)Minified
{"a":1,"b":2}{⏎ "a": 1,⏎ "b": 2⏎}{"a":1,"b":2}
[1,2,3][⏎ 1,⏎ 2,⏎ 3⏎][1,2,3]
{"x":{"y":true}}{⏎ "x": {⏎ "y": true⏎ }⏎}{"x":{"y":true}}

Frequently asked questions

Why does the tool say my JSON is invalid when it looks correct?

Common invisible mistakes include a trailing comma after the last item, single quotes instead of double quotes around keys and strings, or an unquoted key — all valid in JavaScript object literals but not in strict JSON. The validator follows the strict JSON grammar, so any of these will fail even though the text looks similar to valid JavaScript.

What is the difference between JSON and a JavaScript object?

JSON is a text-based data format with a strict grammar: keys must be double-quoted strings, trailing commas are forbidden, and only a fixed set of value types (string, number, boolean, null, object, array) are allowed. A JavaScript object literal is more permissive syntax that also allows unquoted keys, trailing commas, functions, and comments, none of which are valid JSON.

Does minifying change the data represented by the JSON?

No. Minifying only removes whitespace that is not part of any string value; the parsed data structure, and therefore its meaning, is identical before and after. Only the number of bytes needed to transmit or store the text changes.

Can I format deeply nested JSON with this tool?

Yes. Beautifying works recursively on objects and arrays of any depth, indenting each nested level by an additional 2 spaces so the structure stays readable regardless of how deeply it is nested.

This tool validates and reformats standard JSON as defined by RFC 8259; it does not support JSON5, JSONC (comments), or other relaxed JSON dialects, and very large inputs (multiple megabytes) may be slow to process in the browser.

Sources: RFC 8259 - The JavaScript Object Notation (JSON) Data Interchange Format, ECMA-404 - The JSON Data Interchange Syntax

Privacy and safety

  • Runs in your browser — Everything you type is calculated on your own device. Your inputs are never sent to a utilduck server.
  • Encrypted connection — Pages are served over HTTPS, so nobody on the network can read what you load.
  • Not shared with third parties — Your inputs are not passed to analytics or advertising services.
  • Nothing is stored — Results are not saved to any server, and there is no account to create.

Last updated: 2026-08-17