Minify JSON Online — Compress & Shrink JSON Instantly

Left JSON
Right Minified JSON
Ready. Paste JSON on the left, then minify to reduce whitespace.

JSON minification strips the whitespace, line breaks and indentation that make JSON readable, leaving the smallest valid text that carries the same data. This JSON minifier compresses formatted JSON for production APIs, config files and storage — entirely in your browser, so nothing is uploaded and the output is instant.

Updated September 2026 — added measured size savings, gzip comparison and code examples.

What is JSON minification?

Minifying JSON removes every byte the parser does not need: spaces between tokens, newlines, and indentation. Keys, values, ordering and structure are untouched, so minified JSON parses to exactly the same object as the formatted original. It is a lossless, fully reversible transformation — you can format it back at any time.

What minification does not do is shorten your data. Key names, string values and numbers are preserved verbatim. A payload that is large because it has 50,000 rows or very long strings will still be large after minifying.

Minify vs compress vs gzip

These three terms get used interchangeably and they are not the same thing.

  • Minify — removes insignificant whitespace from the JSON text. Lossless, reversible, done once at build time or before sending.
  • Compress (gzip / Brotli) — encodes repeated byte patterns into a smaller binary stream. Applied by your server or CDN in transit, transparently decompressed by the client.
  • Shrink the data itself — shorter key names, fewer fields, pagination, or a binary format. This changes your schema and is the only one of the three that helps when the payload is genuinely big.

The practical answer is that they stack, but not equally. Minification is worth doing whenever you control the output. Compression matters far more. And if you are already serving gzip, minifying adds much less than most guides claim — see the measurements below.

How much smaller is minified JSON?

Measured on real payloads. "2-space" and "4-space" are the pretty-printed originals; "Minified" is the same data with all insignificant whitespace removed.

Payload2-space4-spaceMinifiedSaved vs 2-space
Small API response (1 object, 6 keys)138 B160 B100 B27.5%
Config file (nested, 3 levels)297 B359 B204 B31.3%
Record array (100 rows)17.3 KB21.7 KB11.2 KB35.3%
Record array (1,000 rows)174.0 KB218.0 KB113.0 KB35.1%
Deeply nested (10 levels)1.3 KB2.0 KB451 B64.7%

The pattern: typical savings are 27–35%. Deeply nested structures save far more (65% here) because every level adds indentation to every line. If your source uses 4-space indentation the savings are larger again — the 1,000-row array drops 48% going from 4-space to minified.

What happens once gzip is on

This is the part most minification guides leave out. Compressing both versions tells a different story:

PayloadMinified + gzip2-space + gzipMinifying still saves
Small API response111 B126 B11.9%
Config file161 B183 B12.0%
Record array (100 rows)2.3 KB2.4 KB2.9%
Record array (1,000 rows)21.7 KB22.2 KB2.1%

gzip is extremely good at collapsing repeated whitespace, so it removes most of what minification would have removed. On a 1,000-row array, minifying before gzip saves a further 2.1% — not the 35% the uncompressed figure suggests.

Two practical conclusions. If your server or CDN already compresses responses, minifying JSON is a small optimisation, not a critical one — spend the effort on payload design instead. If compression is not available (embedded devices, some internal services, JSON inlined into a bundle, data written to disk), minification is doing all the work and the full 27–35% applies.

When gzip makes things bigger

Note the small API response above: minified it is 100 bytes, but gzipped it is 111 bytes. gzip adds roughly 18 bytes of header and checksum, so for payloads under a few hundred bytes compression can cost more than it saves. Most servers set a minimum response size before compressing for exactly this reason — typically around 256 to 1,024 bytes.

How to minify JSON

  1. Paste or drop your formatted JSON into the left editor.
  2. Click Minify. The compact output appears on the right, with the before and after byte count.
  3. Copy the result, or download it as a .json file for your build.

Invalid JSON will not minify. If the tool reports an error, run the input through JSON Validator to find the exact line, or JSON Repair to fix common problems automatically. To reverse the process, use JSON Formatter.

Example: before and after

Formatted input:

{
  "id": 1,
  "name": "Phone",
  "price": 499,
  "tags": ["electronics", "mobile"],
  "inStock": true
}

Minified output:

{"id":1,"name":"Phone","price":499,"tags":["electronics","mobile"],"inStock":true}

138 bytes down to 100 — identical data, 27.5% smaller.

Minify JSON in code

For one-off tasks the tool above is faster. For build pipelines, use the language you already ship in.

JavaScript / Node.js

const minified = JSON.stringify(JSON.parse(input));

JSON.stringify emits compact JSON by default — the whitespace only appears when you pass a third argument. Parsing first also validates the input.

Python

import json
minified = json.dumps(json.loads(text), separators=(",", ":"))

The separators argument matters: without it Python inserts a space after every comma and colon, so the output is not fully minified.

Java (Jackson)

ObjectMapper mapper = new ObjectMapper();
String minified = mapper.writeValueAsString(mapper.readTree(input));

Jackson writes compact JSON unless you explicitly enable INDENT_OUTPUT.

Go

var buf bytes.Buffer
if err := json.Compact(&buf, input); err != nil {
    return err
}
minified := buf.String()

json.Compact works on raw bytes without unmarshalling into a struct, so it preserves key order and is fast on large files.

PHP

$minified = json_encode(json_decode($input));

C# (.NET)

using System.Text.Json;
var doc = JsonDocument.Parse(input);
var minified = JsonSerializer.Serialize(doc, new JsonSerializerOptions { WriteIndented = false });

Command line (jq)

jq -c . input.json > output.min.json

-c is compact output. For very large files this streams and will comfortably beat any browser-based tool.

Common issues and fixes

  • Invalid JSON. Minification fails on syntax errors by design — it has to parse before it can re-emit. Use JSON Validator to locate the problem.
  • Trailing commas. Legal in JavaScript, illegal in JSON. Remove them, or let JSON Repair strip them.
  • Comments. JSON has no comment syntax. JSONC and JSON5 files need their comments removed first.
  • Output looks unchanged. The input was probably already minified, or its size is dominated by long string values rather than whitespace.
  • Whitespace inside strings survives. That is correct — spaces and newlines inside a string are data, not formatting, and removing them would change your values.
  • Very large files. Browsers hold the whole document in memory. Past roughly 50 MB, use jq -c or a streaming minifier instead.

When not to minify

  • In development. Readable JSON is worth far more than a few kilobytes while you are debugging.
  • In source control. Minified files produce one-line diffs that are impossible to review. Keep the formatted version committed and minify during the build.
  • In logs. Minified log lines are hard to scan. Size matters less than being able to read an incident at 3am.
  • When gzip is already on and the payload is large. As measured above, you are buying about 2%.
  • As a security measure. Minifying is not obfuscation. Every key and value is still plainly readable.

Minifying in build pipelines

The durable setup is to keep formatted JSON in the repository and generate minified artifacts at build time. That keeps code review readable while still shipping compact files. If you inline JSON into a JavaScript bundle, minify it as part of bundling so you are not shipping indentation inside your app code.

Make it deterministic. Running the same minifier with the same settings across every environment keeps output byte-identical, which keeps CDN cache hits high and stops spurious diffs appearing in release audits.

After minifying, measure. Use JSON Size Analyzer to confirm the payload actually shrank and to see where the remaining bytes are — if one field is carrying most of the weight, no amount of whitespace removal will help.

Frequently asked questions

Does minifying change my data? No. Only insignificant whitespace is removed. Keys, values, types and order are preserved, and the minified text parses to an identical object.

Is minification reversible? Yes, completely. JSON Formatter restores readable indentation. The only thing lost is your original choice of indent width.

How much smaller will my JSON get? Typically 27–35%. Deeply nested data can exceed 60%; flat data with long strings may save under 10%.

Should I minify if my server already uses gzip? It adds roughly 2% on large payloads and about 12% on small ones. Worth doing if it is free in your pipeline, but not a priority.

Is minified JSON faster to parse? Marginally. Parsers skip whitespace cheaply, so the gain is in transfer time, not parse time.

Does this tool upload my JSON? No. Minification runs entirely in your browser. Nothing is sent to a server, which is why it works offline and is safe for confidential payloads.

Can it handle Unicode and emoji? Yes. Unicode characters and escape sequences pass through unchanged.

Does it work on JSON arrays? Yes, on any valid JSON — objects, arrays, or a bare string or number at the top level.

What is the largest file it can handle? That depends on your browser's memory. Tens of megabytes is usually fine; beyond that use jq -c.

Is JSON minification the same as compression? No. Minifying removes whitespace from the text; compression encodes the bytes into a smaller binary form. They are complementary.

Does minifying sort or reorder keys? No. Key order is preserved. If you want sorted keys, use JSON Sort.

Can I minify NDJSON or JSON Lines? Not with this tool — each line is a separate document. Use JSON to NDJSON instead.