json:yaml

JSON formatter

Turn minified or inconsistently indented JSON into something you can read. Formatting also validates, so if it comes out formatted, it parsed.

JSON
JSON

      
Paste JSON to convert.

Conversion happens in this browser tab. Nothing is uploaded, logged, or stored.

Formatting and what it tells you

Paste minified or badly indented JSON and get it back with consistent indentation, one key per line, and structure you can actually scan. The document is parsed first, so formatting doubles as a validity check — if it formats, it is valid JSON.

Indentation is not cosmetic when you are debugging. A missing closing brace is invisible in a single-line document and obvious the moment the nesting is laid out, because the indentation runs off in a direction it should not.

Before and after

Minified
{"order":{"id":"SO-4471","lines":
[{"sku":"A-1001","qty":2}],"paid":true}}
Formatted
{
  "order": {
    "id": "SO-4471",
    "lines": [
      {
        "sku": "A-1001",
        "qty": 2
      }
    ],
    "paid": true
  }
}

Choosing an indent width

WidthWhere it is the convention
2 spacespackage.json, most JavaScript tooling, the default nearly everywhere
4 spacesPython's json.tool, .NET tooling, deeply nested documents that need the extra separation
TabsRare in JSON, but valid — teams that want reviewers to control display width
None (minified)Anything sent over the wire. See the minifier.

Pick one and enforce it with a formatter in CI. Mixed indentation produces diffs full of whitespace noise that hide the real change.

Sorting keys

The sort option alphabetises every object. It is useful for comparing two documents that hold the same data in different orders — sort both and the diff collapses to the genuine differences.

Do not sort files that humans read. In a package.json or a config file, key order carries meaning: name and version belong at the top. Sorting scatters related fields and makes the file harder to navigate.

Formatting from the command line

# jq, the standard tool
jq '.' input.json > formatted.json
jq --indent 4 '.' input.json          # 4-space
jq -S '.' input.json                  # sorted keys

# Python, already installed
python -m json.tool input.json formatted.json

# Prettier, if it is already in your project
npx prettier --write '**/*.json'

Formatting happens locally

A response you are formatting because you cannot read it is, almost by definition, a response you have not inspected yet. Bearer tokens, session identifiers, internal IDs, and personal data all routinely pass through this box on their way to being legible.

They go no further. Formatting is a parse and a re-serialise, both performed by JavaScript in this tab. Nothing is sent anywhere, and closing the tab is all the cleanup required.

Questions people ask

What is the difference between formatting and validating?
Formatting requires valid input, so it validates as a side effect. The JSON validator is the better tool when you expect a failure and want the error explained; the formatter is better when you expect success and want readable output.
Should I sort the keys?
Only for comparing two documents. Sorting collapses a noisy diff into the real differences. Do not sort files people read — key order carries meaning in a package.json or a config file.
What indent width should I use?
Two spaces is the default nearly everywhere, including package.json and most JavaScript tooling. Four is the Python and .NET convention. Pick one and enforce it in CI.
Does formatting change my data?
No. Only insignificant whitespace changes. Parse the formatted output and you get exactly the same value.
Can it format a very large file?
Files up to a few megabytes are fine. Beyond that your browser tab will struggle — use jq on the command line instead.