JSON Formatter

Paste any JSON and format it beautifully, minify it for production, or sort its keys alphabetically — with clear line and column errors when something is invalid.

Everything you need to tame JSON

Beautify with your indent

Pretty-print any JSON with 2-space, 4-space or tab indentation so nested structures become instantly readable.

Sort keys alphabetically

Recursively order object keys A→Z across the whole document, ideal for stable diffs, config files and API fixtures.

Minify for production

Strip all whitespace to produce compact JSON that is perfect for storage, transfer and HTTP payloads.

Precise validation errors

Invalid input is reported with the exact line and column, so you can fix syntax mistakes instead of hunting through the document.

Strict JSON correctness

Parsing follows the JSON spec exactly — trailing commas, single quotes and comments are caught and flagged rather than silently accepted.

Copy & download results

Copy the formatted or minified output with one click, or download it as a .json file for use in your project.

About JSON Formatter

JSON Formatter is a free in-browser tool that beautifies, validates, minifies and sorts JSON data. It reads your input strictly according to the JSON specification and, when the input is valid, rebuilds it with the indentation you choose — or removes all whitespace for a compact minified payload. Every object key can be sorted alphabetically, recursively, which makes the tool perfect for standardizing config files, API responses and test fixtures. Invalid input never breaks the page: instead you get a clear message pointing at the exact line and column of the problem. Because everything runs locally on your device, there are no uploads, no size limits and nothing leaves your computer.

How to format JSON

Three steps from messy JSON to a clean, ready-to-use document.

1

Paste or upload your JSON

Type, paste or upload a .json file into the input pane. The tool accepts any valid JSON — objects, arrays, strings, numbers, booleans and null.

2

Choose your options

Pick 2-space, 4-space or tab indentation, and optionally sort object keys alphabetically before formatting.

3

Format, minify and export

Click Format to pretty-print or Minify to compact the output, then copy it to your clipboard or download it as a .json file.

Things to know

This tool follows strict JSON syntax: trailing commas, single-quoted strings and // or /* */ comments are not valid JSON and will be reported with a precise line and column error. Duplicate keys in an object are collapsed to the last value, matching how most parsers behave. Everything is processed locally in your browser.

JSON Formatter — frequently asked questions