Skip to content

JSON Formatter

Beautify and indent JSON data.

Input
Output

No result

About JSON Formatter

JSON Formatter takes a JSON document — however badly it has been squeezed onto one line — and rewrites it with two-space indentation and a line break per key, so the structure becomes visible instead of implied. Nested objects and arrays are indented by depth, which is usually all it takes to spot a missing bracket or a value that landed in the wrong object.

It doubles as a validity check. Parsing happens before formatting, so anything that is not well-formed JSON is rejected with the parser's own message rather than being reformatted into something that looks plausible. That distinction matters: a formatter that silently "fixes" malformed input hides the error you were trying to find.

The output preserves key order exactly as it appeared in the input — nothing is sorted or normalised. That is deliberate. When you are comparing two API responses to find what changed, reordering the keys would defeat the entire exercise.

The indent width is part of the page rather than a setting, so a house style that calls for tabs, four spaces or a different bracket placement cannot be reproduced here — a separate indent tool exists for the common alternative width. Comments are not tolerated anywhere in the document: JSON has no comment syntax, so a block preceded by // or wrapped in /* */ is a parse error and the formatter will not strip it for you. Duplicate keys are not collapsed or flagged either; the parser keeps the last occurrence and the earlier one vanishes without comment. Nor does the page validate against a schema, so well-formed JSON that violates the shape your API expects will format cleanly and look entirely correct.

How to use JSON Formatter

  1. 1 Paste the JSON into the input box, including the surrounding braces.
  2. 2 Click Convert to reformat it with two-space indentation.
  3. 3 If the document is malformed, an error message is shown in place of the output.

Frequently asked questions

Does it reorder my keys alphabetically?

No. The output keeps the original key order, which is what you want when diffing two versions of the same payload. If you do need sorted keys, the JSON Sort Keys tool sorts them recursively.

What indentation does it use?

Two spaces per level, which is the most common convention for JSON. If your project standardises on four spaces, the JSON Indent (4 spaces) tool produces the same structure at that width.

Will it repair invalid JSON for me?

No, and that is intentional. A trailing comma or an unquoted key is reported as an error with the position, because a formatter that guessed at your intent would hide exactly the defect you were trying to locate.

Does formatting change what the JSON means?

Not at all. Whitespace between tokens is insignificant in JSON, so the formatted document is the same data. Any system that reads the original will read the formatted version identically.

Free, online, and private

Free to use

JSON Formatter is completely free. There is no account to create, no login, and no hidden charge or usage limit.

Runs online in your browser

It is a free online tool that runs entirely in your browser. Nothing to download or install — open the page and start using it right away.

Your data stays private

All processing happens locally on your device. Your input is never uploaded, stored, or tracked, so it never leaves your browser.

How JSON Formatter behaves in detail

These are the specifics of this implementation — the exact ranges, defaults and fixed settings you are working with.

Parameter Value
Indent width 2 spaces, fixed
Key order preserved exactly as given
Parsing whole document, via JSON.parse
Invalid input reported as an error, never repaired

Compiled from the implementation of this tool and checked against it by itoolnet.

What JSON Formatter does not do

Knowing the edges of a tool saves more time than another list of its features. These are the cases where it will not do what you might expect.

  • The whole document must parse before any output is produced — this is a formatter, not a streaming or error-tolerant parser, so one stray comma early in a large file withholds the entire result.
  • Comments are rejected. The strict JSON grammar has no syntax for them, so // and /* */ are parse errors rather than something this tool can strip.

Tested and documented by itoolnet, the team that builds and maintains this site.

Share & embed this tool

Writing a guide or article? You are welcome to link to JSON Formatter with the snippet below. It is free, runs entirely in your browser, and needs no signup.