JSON Formatter

Paste any JSON to format it beautifully, minify it for production, sort its keys alphabetically, or add and remove escape characters — 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.

Escape, copy & download

Add or remove JSON escape characters in one click, then copy the result or download formatted, minified or escaped output.

About JSON Formatter

JSON Formatter is a free in-browser tool that beautifies, validates, minifies, sorts and escapes 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. Escape and Unescape let you add or remove JSON escape characters in one click, so the same content can be embedded in source code, logs or another JSON string. 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, Minify to compact, or Escape/Unescape to add or remove escape characters, then copy the result or download it.

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. Escape and Unescape work on the text as a whole: Escape is idempotent (already-escaped text is left unchanged), while Unescape accepts both bare escaped text and a complete quoted JSON string. Everything is processed locally in your browser.

JSON Formatter — frequently asked questions