100% local

JSON Formatter

data_object Input
task_alt Output

JSON Formatter

Re-indent minified or inconsistently spaced JSON so the structure becomes readable. Pick two spaces, four spaces, or real tab characters, and the whole document is rewritten to match.

Formatting JSON is a parse and re-serialize round trip, not a text transformation. The input is parsed into values, then written back out with the indentation you chose. That distinction matters more than it sounds: anything that is not part of the parsed value cannot survive the trip, and anything the parser normalizes stays normalized in the output.

The practical benefit is that formatting doubles as validation. A trailing comma, an unquoted key, or an unbalanced bracket fails at the parse step and is reported instead of silently producing broken output. When an API response will not load in your code, running it through the formatter is the fastest way to find out whether the payload itself is malformed or your parsing code is at fault.

What changes besides whitespace

Indentation is the only thing you asked to change, but a parse and re-serialize cycle normalizes numbers as a side effect. JSON has one numeric type and JavaScript reads it as a double, so the written form of a number is regenerated from its value rather than copied. The literal 1.0 comes back as 1, 1e3 becomes 1000, and 0.10 becomes 0.1. The numeric value is identical in every case, but the text is not byte for byte what you pasted.

Integers larger than 2 to the 53rd power cannot be held exactly in a double, so they are the one case where formatting genuinely loses information. Paste 12345678901234567890 and the output reads 12345678901234567000. If your payload carries large IDs, snowflake identifiers, or currency values as bare numbers, treat any JSON tool that round trips through a native parser as unsafe for those fields, this one included. Sending such IDs as strings is the usual fix, and it is worth doing at the API level.

Key order is preserved for ordinary keys, because objects keep insertion order. Keys that look like array indices are the exception: integer-like keys are always visited in ascending numeric order and placed ahead of every string key. An object written as 10, 2, b, a comes back as 2, 10, b, a. This is a property of the object model underneath, not a choice the formatter makes, and every browser based JSON tool behaves the same way.

Normalizations applied during formatting

Each row is a real input and the exact output this tool produces. Only the last two rows change anything you would notice in your data.

InputOutputNotes
1.01Trailing zeros are dropped. The value is unchanged.
1e31000Exponent notation is expanded when the plain form is shorter.
0.100.1A leading zero is kept, a trailing one is not.
{"a":1,"a":2}{"a":2}Duplicate keys are legal to parse but only the last one survives. Nothing warns you.
{"10":1,"2":1,"b":1}{"2":1,"10":1,"b":1}Integer-like keys sort numerically and move ahead of string keys.
1234567890123456789012345678901234567000Beyond 2^53 the value itself changes. This is the one lossy case.

Formatting a minified response

A typical minified API payload, formatted with two space indentation.

Input
{"id":42,"user":{"name":"Ada","tags":["admin","dev"]},"active":true}
Output
{
  "id": 42,
  "user": {
    "name": "Ada",
    "tags": [
      "admin",
      "dev"
    ]
  },
  "active": true
}

Notice that the nested object and the array each gain one indentation level, and that array elements sit on their own lines. The values are untouched.

Common Pitfalls

Tab indentation is not the same as one space

A common bug in JSON formatters is passing the number 1 when the user asks for tabs, because the serializer treats a number as a space count. The result is one space per level, not a tab. This tool passes an actual tab character, so the Tab setting produces tab indented output that your editor will show at your configured tab width.

Formatting cannot fix JSON with comments or trailing commas

Comments and trailing commas belong to JSON5 and JSONC, not to JSON. The parse step rejects them, so you get an error rather than cleaned up output. If you are formatting a tsconfig.json or a VS Code settings file, strip the comments first or use a JSONC aware tool.

{
  // not valid JSON
  "a": 1,
}

Do not use formatting to canonicalize for signature checks

Because numbers are normalized and duplicate keys collapse, formatted output is not a canonical form you can hash and compare against a signature produced elsewhere. Use a canonicalization scheme such as JCS if you need byte stable output across implementations.

How to Use

  1. Paste your JSON: Drop in a response body, a config file, or anything that currently sits on one long line.
  2. Choose indentation: Select your preferred indentation style: 2 spaces, 4 spaces, or tab.
  3. Click Format: Press the Format button to beautify your JSON. The formatted output appears on the right.

Key Features

  • Multiple indentation options: 2 spaces, 4 spaces, or tabs
  • Preserves all data values: only whitespace is changed
  • Instant formatting with syntax error detection
  • One-click copy of formatted output

Use Cases

  • Making minified API responses readable for debugging
  • Standardizing JSON indentation across a team or project
  • Preparing JSON for documentation or code reviews

Frequently Asked Questions

What indentation options are available?

Two spaces, four spaces, or a tab character. The tab option emits a real tab, so the visible width follows your editor setting rather than being fixed at one space.

Does formatting change my JSON data?

Values are preserved, but the text of numbers is regenerated. 1.0 is written as 1 and 1e3 as 1000, which parse to the same values. Integers beyond 2^53 are the exception and do lose precision.

Can I format invalid JSON?

No. The formatter requires valid JSON input. If your JSON has syntax errors, an error message will indicate what needs to be fixed.

Is there a size limit?

There is no hard limit. PureJSON can format large JSON files quickly, limited only by your browser's available memory.

Can I format JSON with comments or trailing commas?

No. Standard JSON does not allow comments or trailing commas. Remove them first, then paste valid JSON to format it.

Why did my large ID number change?

JSON numbers are read as double precision floats, which hold integers exactly only up to 2^53. A 20 digit ID gets rounded during parsing, before formatting even happens. Ask the API to send such IDs as JSON strings, which is the standard workaround.

Does formatting preserve the order of my keys?

Ordinary keys keep their original order. Keys that consist only of digits are an exception: they are emitted in ascending numeric order and placed before all other keys, because that is how the underlying object model stores them.