$ SudoStuff

JSON Formatter

Format, validate and minify JSON instantly.

Processed locally in your browser. Nothing you type here is sent to our servers.

What is the JSON formatter?

JSON is easy for machines to read and, once it arrives on one line with no spaces, genuinely painful for people. This tool takes JSON in any state — minified, badly indented, or broken — and gives you back something you can actually read, along with a precise explanation when it will not parse.

It does three related jobs: format re-indents the document, minify strips every byte that is not meaningful, and validate checks the syntax and tells you what the document contains without changing your output.

How to use it

  1. Paste your JSON into the input panel, or pick one of the examples.
  2. Choose your indentation — two spaces, four spaces, or a tab.
  3. Press Format, or use ⌘/Ctrl + Enter.
  4. Copy the result, or download it as a .json file.

Tick Sort keys to order object properties alphabetically. This is useful before comparing two documents by eye, since it removes key order as a source of difference. Array order is never touched, because reordering an array changes what the document means.

Reading the error messages

When JSON will not parse, the error panel names the line and column and explains the problem in plain language — “trailing comma before the closing bracket” rather than “Unexpected token”. The offending line number is highlighted in the gutter.

The mistakes that come up most often:

  • A trailing comma after the last property or array item. JavaScript allows it; JSON does not.
  • Unquoted keys. {name: "x"} is a JavaScript object literal, not JSON. Keys need double quotes.
  • Single quotes. JSON strings only ever use double quotes.
  • Raw line breaks inside a string. These must be escaped as \n.
  • Comments. JSON has no comment syntax, however much we all wish it did.

Common use cases

  • Making an API response readable when your client returned it on one line.
  • Checking that a config file or fixture is valid before committing it.
  • Normalising indentation across files so diffs stay small.
  • Sorting keys on two payloads so you can see what genuinely differs.
  • Minifying a payload to see how large it actually is on the wire.

Limitations

  • Formatting parses the document into JavaScript values and re-serialises it. Numbers therefore round-trip through IEEE 754 doubles: an integer larger than 253, such as a Twitter-style ID, will lose precision. Keep those as strings.
  • Duplicate keys in the same object are not an error in JSON, and the last one wins. The formatter will silently keep only that one.
  • Everything runs in your browser, so extremely large documents are limited by your device's memory rather than by a server.
  • Key order is otherwise preserved exactly as written unless you enable sorting.
↑↓ navigate ↵ open esc close