DevKits

JSON Minifier — Compact & Minify JSON Online

Minify JSON online — remove all whitespace and see exact bytes saved. Guarantees a valid, spec-compliant output. 100% local, no upload.

Last updated:

284 B
284 chars · 11 lines
229 B
Original
284 B
Minified
229 B
Saved
19.4%(55 B)

Paste JSON to strip every non-essential whitespace character and see the exact bytes saved. Output is always a valid, RFC 8259 compliant JSON string — verified by round-tripping through JSON.parse and JSON.stringify. 100% local.

What is JSON Minifier?

A JSON minifier removes indentation, line breaks, and whitespace between tokens to produce the smallest possible representation of a JSON document. The saving is meaningful anywhere bytes matter: embedding payloads in URLs or QR codes, storing snapshots in a database column, shipping bundles to the browser, or sending data over slow / metered networks. Because JSON is whitespace-insensitive outside of string literals, minifying is fully lossless — every parser will read the compact form and the pretty-printed form as the exact same value. This tool parses your input with the native JSON.parse then re-serializes with JSON.stringify, so the output is guaranteed to be spec-compliant, and you get a precise before/after byte count.

How to minify JSON online

  1. 1Paste your JSON (pretty-printed or already partially compacted) into the left editor.
  2. 2The right pane immediately shows the minified single-line output.
  3. 3Read the byte-count card below: original size, minified size, and percentage saved.
  4. 4Copy the compact output, or fix any parsing errors flagged on the input side with 'Jump to line'.

Use Cases

Shrink API payloads

For non-gzipped endpoints (embedded devices, WebSocket messages, mobile with poor gzip support), minifying can cut bytes on the wire by 20-40% and speed up parsing on the client.

Embed JSON in URLs and QR codes

Every whitespace character counts against your character budget. Minifying before base64-encoding is a common preprocessing step for shareable links.

Ship JSON in a bundle

Static JSON imported into a JS bundle keeps every extra byte in the final chunk. Minifying source data before build reduces the bundle by kilobytes for large fixtures.

Database column storage

When storing a JSON snapshot in a text/JSONB column, minifying reduces row size, cache footprint, and I/O — noticeable at scale.

Code Examples

Programmatic minify (Node / browser)

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

Programmatic minify (Python)

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

Command line with jq

jq -c . input.json > minified.json

Key Concepts

Whitespace insensitivity
Per RFC 8259, spaces, tabs, carriage returns, and line feeds are allowed between any two structural tokens but carry no meaning. Removing them is guaranteed lossless.
Minify vs. compress
Minifying removes redundant characters at the JSON syntax level. Compression (gzip, brotli) operates on the byte stream and can further shrink a minified payload — the two are complementary, not overlapping.
Key order preservation
JSON.stringify serializes object keys in the order returned by Object.keys — insertion order for string keys. Minifying does not sort keys; use a JSON sort tool if you need a canonical form for diffing or hashing.
Byte count vs. character count
This tool reports UTF-8 byte counts, which is what actually travels on the wire and what most storage backends charge for. Non-ASCII characters (CJK, emoji) can occupy 2-4 bytes each even though they render as one glyph.

Tips & Best Practices

  • gzip already collapses runs of whitespace efficiently — pre-minifying a gzipped API response only saves a few percent. The win is much larger for uncompressed transports.
  • If your API sits behind a CDN with automatic minification, don't double-minify — measure first.
  • For canonical JSON (for hashing, signing, or diffing), you need a spec like RFC 8785 (JCS) that also sorts keys and normalizes numbers. Plain minifying is not canonical.
  • Minified JSON is technically valid but often unreadable in logs — keep pretty-printed copies for debugging and minify only at the transport layer.
  • For very large documents, streaming minification (stream-json in Node) avoids loading the whole file into memory.

Frequently Asked Questions

How much size does minifying JSON typically save?

For pretty-printed JSON with 2-space indent, expect 20-40% reduction. Larger nested payloads with many keys can save 50% or more. The tool reports exact original vs. minified byte counts and the saving percentage.

Is the output still valid JSON?

Yes. The minifier parses your input with JSON.parse and re-serializes with JSON.stringify, so the result is always RFC 8259 compliant. Invalid input is rejected with the exact error location.

When should I minify JSON?

Anywhere bytes matter: embedding config in a URL, sending payloads over slow / metered networks, storing snapshots in a database column, or shipping static bundles. For HTTP APIs, gzip already compresses redundant whitespace efficiently, but pre-minified bodies still reduce parser workload on the client.

Does minifying change the semantic meaning?

No. JSON is whitespace-insensitive between tokens — removing spaces, tabs, and newlines outside of string literals does not change the resulting value. Object key order is preserved because JSON.stringify walks Object.keys in insertion order.

Is my JSON uploaded to any server?

No. All processing happens locally in your browser. The input never leaves your device.

Related Tools