Skip to main content
CodeLint.Dev Dev Tools

JSON Minifier — Strip Whitespace & Compress

Reduce a JSON document to its smallest valid form. Validates before compressing, so a syntax error is reported rather than silently producing malformed output.

Input

Paste your JSON here, or drag a file…

Drag & drop a file, or paste content above

Output

Output will appear here

What minifying does, and what it does not

Minification removes every character a JSON parser ignores: the spaces, tabs, newlines and carriage returns that sit between tokens. Nothing else changes. Keys keep their names, values keep their types, arrays keep their order, and whitespace inside a string value is untouched — {"note": "hello world"} keeps both spaces, because those are data.

The saving depends entirely on how the original was formatted. A deeply nested document indented with four spaces can lose 60% of its bytes; a shallow one that was already compact might lose 10%.

What minification does not do is compress in any meaningful sense. It removes redundant characters; it does not encode the remaining ones more efficiently. If size genuinely matters, gzip or Brotli will do far more — a typical JSON payload compresses to 10–20% of its original size, because JSON is extremely repetitive (every object repeats its key names in full).

That has a practical consequence worth knowing: if your server already applies gzip or Brotli, minifying first buys you very little. The compressor collapses runs of whitespace almost perfectly on its own. Measure both before adding a minification step to a build.

Where minifying is and is not worth it

SituationWorth minifying?Why
API response over HTTP with compression onMarginalBrotli already removes the whitespace. Expect a few percent, not 50%
API response with no compressionYesEvery byte is transmitted literally; this is the case minification is for
Embedded in a URL or query parameterYesURL length limits are real, and whitespace percent-encodes to three bytes per character
Stored in a database columnUsually yesStorage and index size scale with the raw bytes; most engines do not compress per-row
Config file in version controlNoFormatting is what makes diffs readable. Minifying makes every change a one-line rewrite
Firmware or embedded device payloadYesParsing memory is often the constraint, and it scales with document length
localStorage or a cookieYesBoth have hard size quotas — 5MB and 4KB respectively

Minifying in code

JavaScript
// Omitting the space argument produces minified output
const minified = JSON.stringify(data);

// Round-tripping normalises formatting from any source
const minify = (text) => JSON.stringify(JSON.parse(text));
Python — mind the default separators
import json

# Python's default separators leave a space after ':' and ','
json.dumps(data)                              # {"a": 1, "b": 2}

# Pass separators explicitly for genuinely minimal output
json.dumps(data, separators=(',', ':'))       # {"a":1,"b":2}
Command line
# jq -c emits one compact line
jq -c . input.json > output.json

# Check the saving
wc -c input.json output.json

About

The JSON Minifier strips every unnecessary space, tab, newline, and carriage return from a JSON document, producing the most compact valid representation on a single line. Reducing payload size matters for API performance, mobile data usage, embedded firmware configs, and any situation where JSON is transmitted over a network or stored in a size-constrained environment. The minifier validates the input before compressing it, so you will know immediately if your JSON has a syntax error rather than silently producing malformed output. Processing happens entirely in your browser — no data is uploaded anywhere.

How to use

  1. 1 Paste your formatted or pretty-printed JSON into the input box on the left.
  2. 2 The minified output appears automatically in the right panel — no button press required.
  3. 3 If your JSON has a syntax error, a warning will appear instead of a minified result.
  4. 4 Click the Copy button to copy the compact single-line output to your clipboard.
  5. 5 Paste the minified JSON directly into your API request, config file, or build script.
How much does minifying JSON reduce file size?
Minification typically reduces JSON size by 30–60%, depending on how heavily indented the original is. A deeply-nested object formatted with 4-space indentation will see the greatest reduction. For API responses with many nested objects, the saving is often significant enough to meaningfully improve response times on slow connections.
Will minifying change the data or structure of my JSON?
No. Minification only removes insignificant whitespace outside of string values. Data values, keys, arrays, and objects are completely unchanged — any JSON parser will read the minified output as identical to the original. String values that contain whitespace (e.g. "hello world") are never touched.
Is my JSON validated before minifying?
Yes. The minifier parses the JSON before compressing it. If your document has a syntax error — a trailing comma, a missing bracket, an unquoted key — the tool will report the error instead of producing potentially malformed compact output.
When should I minify JSON?
Minify JSON for production API responses, embedded config files, CDN-hosted data files, or any payload transmitted over a network where bandwidth or payload size matters. For files you need to read or edit by hand, keep the formatted version and minify only at build or deploy time.
Is my data sent to a server?
No. Minification runs entirely in your browser using JavaScript. Your JSON never leaves your device, which makes this tool safe for minifying payloads that contain API keys, authentication tokens, or any sensitive data structure.