DataShift

JSON Formatter & Minifier

Paste compact JSON and make it readable, or paste pretty-printed JSON and compact it for production. Validates syntax automatically — errors show the exact line and position.

Two modes, one tool

Mode 1

Pretty print with configurable indentation

Choose 2-space, 4-space, or tab indentation to match your team's style guide. Formatting also validates the JSON — syntax errors are caught immediately with the exact line and position.

Mode 2

Minify for production

Strips all non-essential whitespace. The data is identical — only the formatting changes. A 10KB pretty-printed config becomes 4KB minified, shaving every API response.

Why formatting matters

Code review

Minified JSON in a pull request diff is unreadable. Format it first and reviewers can actually see what changed.

API debugging

A 400-character minified response is impossible to scan. Pretty-print it and the missing field or wrong nesting level is immediately obvious.

Production performance

Config files and API responses served minified load faster. A 30% size reduction means 30% less to parse on every request.

Validation as a side effect

Formatting requires parsing. If your JSON has a trailing comma, mismatched brackets, or a single-quoted string, you'll know immediately — before it reaches your application.

Example

Stripe Payment Intent — minified API response formatted for readability

Input (minified)
{"id":"pi_3MtwBwLkdIwHu7ix","amount":2000,"currency":"usd","status":"succeeded","customer":{"id":"cus_Nffr","email":"jenny@example.com"}}
Output (2-space indent)
{
  "id": "pi_3MtwBwLkdIwHu7ix",
  "amount": 2000,
  "currency": "usd",
  "status": "succeeded",
  "customer": {
    "id": "cus_Nffr",
    "email": "jenny@example.com"
  }
}

No data changed — only whitespace was added. The formatted version is easier to read, review, and debug. The minified version is what you ship.

Frequently asked questions

Does formatting change the data at all?

No. Formatting only changes whitespace — spaces, tabs, and newlines. The keys, values, ordering, and structure are completely unchanged. Minifying and then pretty-printing produces identical data to the original.

What happens if my JSON has a syntax error?

The formatter stops and shows the error message from the JSON parser, including the position of the problem. Common issues: trailing commas (valid in JavaScript, invalid in JSON), single-quoted strings, unquoted keys, and missing colons.

What is the difference between 2-space and 4-space indentation?

None functionally — both produce valid JSON. 2-space is common in JavaScript projects (Prettier's default). 4-space matches Python and many config-file conventions. Tab is useful when your editor is set to display tabs as a consistent width.

How much smaller is minified JSON compared to pretty-printed?

Typically 20–40% smaller, depending on how deeply nested the structure is. More nesting means more indentation whitespace to remove. A config with lots of short scalar values compresses less than a deeply nested API response.

Can I format JSON with comments (JSON5 or JSONC)?

Not directly — comments are not valid JSON and the standard parser rejects them. If your file has // or /* */ comments, remove them first or use a JSON5 parser. Our JSON validator can also help identify and strip non-standard syntax.