DataToolsLab
JSON Tools

JSON Formatter

Format and prettify messy or minified JSON.

Loading tool…

What is JSON Formatter?

The JSON Formatter takes compact, minified, or inconsistently-indented JSON and reformats it with consistent indentation, line breaks, and an optional alphabetical key order — never uploading your data.

How it works

We parse your input with a hand-rolled recursive-descent tokenizer so we can report exact line and column error positions when the JSON is malformed. On success, we re-emit the value with the indent you chose, optionally sorting keys at every level for deterministic output (great for diffs and version-controlled config).

  1. Paste or drop a JSON file. Drop a .json file onto the input pane, click Browse, or paste text. Auto-format-on-paste is on by default.
  2. Pick your indent and options. Choose 2 / 4 spaces or tabs. Toggle Sort keys and/or Minify. Errors are marked inline in the input pane with the failing line and column.
  3. Copy or download. Use Copy to send the formatted output to your clipboard, or Download to save as a .json file. The byte counts of input vs. output are shown so you can see the size impact.

Examples

{"a":1,"b":[2,3]}

Default 2-space indent produces a four-line block: \n{\n \"a\": 1,\n \"b\": [\n 2,\n 3\n ]\n}.

Sort keys on

Object keys become alphabetically ordered at every level — useful for deterministic diffs and clean version-controlled config.

Common mistakes

Trailing commas

Strict JSON forbids trailing commas. The Validator marks them so you can fix JSONC / JSON5 before formatting.

Single-quoted strings

JSON requires double quotes for strings. Use single quotes only inside string values.

Alternatives

JSON Minifier

The inverse tool — collapses formatted JSON into a single compact line.

JSON Validator

If you're getting an error, the Validator pinpoints the exact line and column.

Frequently asked questions

Is my JSON uploaded to a server?

No. The formatter parses and re-emits your JSON entirely in your browser — your data never leaves your device.

Does it preserve my original key order?

By default yes. Toggle 'Sort keys alphabetically' to recursively sort every object's keys for deterministic output.

Can it format really large files?

JSON.parse handles files in the low-MB range comfortably on the main thread. For very large files a future Web Worker pass would offload parsing; today we recommend splitting inputs above ~10MB.

Online