{jsonbody.com}

JSON Minifier / Beautifier

Minify JSON online to strip whitespace and shrink its size, or beautify it into indented text. Validates your input, can sort keys and shows the bytes saved.

Loading…

Minify or beautify JSON in one place

Minifying removes every space and line break that JSON does not need, which makes the data smaller to store and send. Beautifying does the opposite, adding indentation so that people can read it. This page does both and shows how many bytes the change saved.

Your input is validated at the same time. Invalid JSON produces an error instead of partly formatted output, so the tool also works as a quick syntax check.

How to use it

  • Paste JSON into the left pane, or open a file.
  • Choose Minify or Beautify. The result updates as you type.
  • When beautifying, pick the indent size. Turn on Sort keys A to Z to get a stable order.
  • Copy the output, download it, or press swap to continue working on it in the other mode.

Example

The same object in both forms. Only the whitespace differs, so a program reads them as identical data.

Beautified and minified
{
  "user": {
    "id": 9007199254740993,
    "tags": ["admin", "beta"]
  }
}

{"user":{"id":9007199254740993,"tags":["admin","beta"]}}

Large numbers and long IDs stay exact

Many online formatters parse your JSON into JavaScript numbers and print it again. Any value above about 9 quadrillion then gets silently rounded, so 9007199254740993 can become 9007199254740992. This tool works on the text itself, so digits and string contents are preserved exactly as you wrote them.

When sorting keys and minifying help

Sorted keys make two versions of a document easy to compare, because a change in key order no longer appears as a difference. Pair this with our Text Compare tool when reviewing config changes. Minifying is most useful for values stored in a database column, embedded in HTML or passed in a message queue. For API responses, gzip or Brotli compression at the server already removes much of the repetition, so minified JSON saves less over the wire than the raw byte count suggests. It still reduces the work done to parse whitespace, which can matter at high volume.

Frequently Asked Questions

Does minifying change my data?

No. It only removes whitespace outside strings. Spaces inside string values are kept.

Will sorting keys break anything?

JSON objects are unordered by definition, so correct parsers do not care. Only code that wrongly depends on key order would notice.

Why does the tool reject my input?

Common causes are trailing commas, single quotes and unquoted keys. All of these are valid in JavaScript but not in JSON.

Can I minify a file with comments?

JSON does not allow comments, so remove them first. Files like JSON5 and JSONC are different formats, despite the similar syntax.