Minify JSON Online: Compress JSON Instantly

Last updated:

JSON minification strips whitespace outside string values — spaces, tabs, and newlines — while leaving the parsed data byte-for-byte identical. A 4-space indented file shrinks 20–40%; combined with gzip the total reduction reaches 80–90%. In JavaScript, 1 call does it: JSON.stringify(JSON.parse(input)) with no 3rd argument. In Python: json.dumps(data, separators=(',', ':')). On the command line: jq -c . or python3 -m json.tool --compact. On a 1 MB payload at 10 Mbps, minification alone saves 200–400 ms in transfer time. This guide covers 4 methods, browser vs server minification tradeoffs, and when to keep formatted JSON in source control and config files.

Paste your JSON into Jsonic's JSON Formatter and click Minify to compress it in your browser.

Minify JSON online

What JSON minification does

Pretty-printed JSON is easy to read because it uses indentation and line breaks. Minified JSON is optimized for transfer and storage because it removes that whitespace.

// Pretty printed
{
  "user": {
    "name": "Alice",
    "active": true
  },
  "roles": ["admin", "editor"]
}

// Minified
{"user":{"name":"Alice","active":true},"roles":["admin","editor"]}

Whitespace inside string values is preserved. A value like "first last"stays exactly the same.

How to minify JSON online

  1. Open Jsonic's JSON Formatter.
  2. Paste your JSON into the editor or upload a .json file.
  3. Click Validate if you want to check syntax first.
  4. Click Minify to compress the JSON into one line.
  5. Click Copy or Download to save the result.

The minifier parses the JSON before compressing it. If the input has a trailing comma, bad quote, or missing bracket, you get a syntax error instead of broken output.

Minify JSON in JavaScript

Use JSON.stringify without the third spacing argument:

const input = '{"name":"Alice","roles":["admin","editor"]}'
const data = JSON.parse(input)
const minified = JSON.stringify(data)

console.log(minified)
// {"name":"Alice","roles":["admin","editor"]}

If you already have a JavaScript object, pass it directly to JSON.stringify. See the JSON.stringify tutorial for replacers, spacing, and safe serialization patterns.

Minify JSON in Python

Python's json.dumps keeps a small space after commas and colons by default. To produce the most compact output, pass separators=(',', ':').

import json

data = {"name": "Alice", "roles": ["admin", "editor"]}
minified = json.dumps(data, separators=(',', ':'))

print(minified)
# {"name":"Alice","roles":["admin","editor"]}

For the opposite workflow, use json.dumps(data, indent=2). The format JSON in Python guide covers indentation, files, and python -m json.tool.

When to minify JSON

Use caseWhy minify
API payloadsReduces bytes sent over the network
Embedded configKeeps generated files compact
Local storageUses less browser storage for cached data
Logs and queuesFits more events in the same storage budget

For code review, debugging, and documentation, pretty-printed JSON is usually better. Minify only when compact output matters.

File size comparison

Minification savings depend on nesting and indentation. Deeply nested objects with many keys save more space than short flat objects.

Pretty printed: 148 bytes
Minified:       73 bytes
Saved:          75 bytes (51%)

Compression such as gzip or Brotli reduces both versions further, but minifying first still avoids sending whitespace that parsers do not need.

Frequently asked questions

What does minify JSON mean?

Minifying JSON removes whitespace outside string values — spaces, tabs, and line breaks — turning readable formatted JSON into compact one-line JSON. The data does not change; only unnecessary whitespace is removed.

Is minified JSON still valid JSON?

Yes. JSON parsers ignore whitespace outside string values, so minified JSON and pretty-printed JSON represent the same data and parse to identical objects.

How do I minify JSON in JavaScript?

Parse the JSON string, then call JSON.stringify(data) without a spacing argument: JSON.stringify(JSON.parse(jsonString)). The spacing argument (third parameter) controls indentation — omitting it or passing 0 produces minified output.

How much does minifying JSON reduce file size?

A JSON file formatted with 4-space indentation typically shrinks by 20–40% when minified. Deeply nested objects shrink more. Combined with gzip compression, total size reduction reaches 80–90% versus a formatted, uncompressed file.

Does minifying JSON affect performance?

Yes, positively. Minified JSON transfers faster and parses faster — the parser scans fewer bytes. For a 1 MB JSON file on a 10 Mbps connection, minification alone can cut transfer time by 200–400 ms.

How do I minify JSON in Python?

Pass separators=(',', ':') to json.dumps: json.dumps(data, separators=(',', ':')). The default separators include spaces after each comma and colon. From the command line: python3 -c "import json,sys; print(json.dumps(json.load(sys.stdin)), end='')" < input.json.

Compress JSON in your browser

Use Jsonic's formatter to validate, pretty print, and minify JSON without uploading your data.

Open JSON Formatter