Skip to main content
Back to tools

JSON Formatter

Prettify and minify JSON with indentation control

About JSON Formatter

Pretty-prints JSON with 2-space, 4-space or tab indentation, or collapses it onto a single line with Minify. The text is parsed and re-serialized, so the result is always valid JSON with consistent spacing, whatever the original layout. Useful for reading API responses, log payloads and config files, and everything runs locally in your browser.

Category: Encoding.

Frequently asked questions

What's the difference between format and minify?

▾

Formatting adds indentation and newlines for human readability. Minifying removes all whitespace to reduce file size — useful for production bundles or API responses.

Can I use this to validate JSON?

▾

Yes. Format and Minify parse the input first, and invalid JSON shows the browser parser's error message instead of output, often with the line and column. The JSON Validator runs the same check and also reports the root type and the number of top-level keys or items.

What indentation size should I use?

▾

2 spaces is the most common convention for JSON: it's Prettier's default and the way npm writes package.json. 4 spaces matches the output of Python's json.tool, and tabs let each reader choose their own display width.

Can formatting change my data?

▾

Rarely, but the input is parsed and re-serialized with JSON.parse and JSON.stringify rather than just re-indented. Integers larger than 2^53, such as 64-bit IDs, lose precision, duplicate keys keep only their last value, integer-like keys such as "10" move before the others, and numbers are normalized, so 1.0 becomes 1.

Related tools