JSON

JSON Formatter

Format and beautify JSON instantly in your browser. It changes only whitespace, so numbers and keys stay exactly as you wrote them.

Ready. Press Ctrl+Enter to format.

What it does

JSON Formatter checks that your text is valid JSON, then re-indents it or compresses it to one line. It changes only whitespace: numbers, key order and string escapes come out exactly as you typed them, so large IDs and values such as 1.10 are not rounded or rewritten.

How to use

  1. Paste valid JSON into the input area.
  2. Choose an indent size, then select Format or Minify. Ctrl+Enter also formats.
  3. Copy the output when you are done.

Duplicate keys

A JSON object should not repeat a key, and most parsers silently keep only the last value. The formatter keeps every occurrence and warns you, so you can fix the source.

Example

Paste this one-line document and select Format with a 2-space indent:

{"name":"Ada","id":12345678901234567890,"price":1.10,"tags":["x","y"],"z":{"b":2,"a":1}}

The output keeps every value exactly as written, including the 20-digit id and 1.10:

{
  "name": "Ada",
  "id": 12345678901234567890,
  "price": 1.10,
  "tags": [
    "x",
    "y"
  ],
  "z": {
    "b": 2,
    "a": 1
  }
}

Format, Minify, Sort keys and Repair

  • Format re-indents the document with 2 spaces, 4 spaces or a tab. Only whitespace changes.
  • Minify removes all whitespace outside strings and puts the document on one line. The JSON Minifier shows how many bytes that saves.
  • Sort keys orders object keys alphabetically at every level, so the key order does change. Use it to make two documents easier to compare, for example {"name":"Ada","z":{"b":2,"a":1},"b":1} becomes an object that starts with "b" and has "a" before "b" inside "z".
  • Repair tries to fix common mistakes such as single quotes, unquoted keys, trailing commas and Python-style True. For a full list of what was changed, use the JSON Repair tool.

Why large numbers and 1.10 stay exact

JavaScript reads every JSON number as a 64-bit floating-point value. Integers above 9007199254740991 cannot all be represented, so a tool that parses and then re-serializes the document would turn 12345678901234567890 into 12345678901234567000 and 1.10 into 1.1. That silently corrupts IDs, timestamps and prices. This formatter never re-serializes numbers: it reads the text and rewrites only the whitespace around it.

Frequently asked questions

Is my JSON uploaded anywhere?

No. The formatter runs in your browser, and the text you enter is not sent to a server.

What is the difference between formatting, validating and minifying?

Formatting adds indentation so the document is readable. The JSON Validator checks the syntax and explains errors. Minifying removes whitespace to make the document smaller. The formatter also checks that the JSON is valid before it re-indents it.

Can I format JSON that has comments or trailing commas?

Formatting needs valid JSON, and strict JSON has no comments or trailing commas. Use Repair, or the JSON Repair tool, to fix those first.

Does formatting change the order of my keys?

No. Format and Minify keep the keys in the order you wrote them. Only Sort keys changes the order.

What happens with duplicate keys?

Both occurrences are kept in the output and you are warned, because most parsers silently keep only the last value.

Privacy

The formatter uses your browser's built-in JSON parser and runs entirely on your device. No request is sent to a server with the text you enter.

Share this tool

Your data is not included in this link.