Minify JSON Online
Paste formatted or indented JSON below. The minifier validates it first, then removes all non-essential whitespace — showing you the exact byte savings before you copy it.
JSON Minifier
Remove all whitespace from JSON to produce the smallest possible output. Runs entirely in your browser — no data sent to any server.
What is JSON minification?
JSON minification removes all whitespace characters — spaces, newlines, and tabs — that are not part of string values. The resulting JSON is semantically identical: all keys, values, arrays, and nesting are preserved, but the file is as compact as possible.
Minified JSON is used in production APIs and web applications to reduce payload size and improve transfer speed. A typical pretty-printed JSON file is 20–40% larger than its minified equivalent. For high-traffic APIs serving millions of requests, minifying JSON responses meaningfully reduces bandwidth costs and latency.
This tool parses your JSON first to validate it, then re-serializes it without any whitespace using JSON.stringify(parsed). Invalid JSON is rejected with an error message — you can't minify what you can't parse.
When to minify JSON
- API responses — minify JSON before sending over HTTP. Combine with gzip/Brotli compression for maximum reduction (whitespace compresses well, so the combined savings are significant).
- Configuration files in source control — minify large JSON config files to reduce diff noise and file size.
- Cookies and localStorage — minify JSON before storing in browser cookies (4KB limit) or localStorage.
- Embedded JSON in HTML — minify JSON injected into
<script>tags ordata-attributes to reduce HTML size. - Build pipelines — minify JSON assets (translation files, config) as part of a production build step.
Minify JSON in code
JSON.stringify(JSON.parse(jsonString))import json; json.dumps(json.loads(json_string), separators=(',', ':'))import bytes; var buf bytes.Buffer; json.Compact(&buf, []byte(jsonString))json_encode(json_decode($jsonString))require 'json'; JSON.parse(json_string).to_jsonecho '$json' | jq -c .python3 -c "import sys,json; print(json.dumps(json.load(sys.stdin),separators=(',',':')))"Frequently asked questions
Does minifying JSON change the data?▾
No. Minification only removes insignificant whitespace — spaces, tabs, and newlines between tokens. All keys, values, nesting, and ordering are preserved exactly. The minified JSON parses to an identical JavaScript object.
Does minification work with JSON arrays?▾
Yes. Any valid JSON value can be minified — objects, arrays, strings, numbers, booleans, and null. Paste an array or a deeply nested document and the tool handles it.
What is the difference between JSON minify and JSON compress?▾
Minification removes whitespace (lossless, within the JSON format). Compression (gzip, Brotli, zstd) further reduces size by encoding repeated byte patterns. Most web servers apply gzip on top of minified JSON automatically via content-encoding. For best results, do both: minify first, then let your server compress.
Why does minified JSON still have spaces inside strings?▾
Whitespace inside JSON string values is part of the data — removing it would change the content. Only whitespace between tokens (after colons, after commas, between brackets) is removed. For example, " hello world " keeps its spaces; the key: value separator does not.
Can I minify JSON from the command line?▾
Yes — jq is the most common tool: echo '{"a": 1}' | jq -c . The -c flag outputs compact (minified) JSON. You can also use Python: python3 -c "import sys,json; print(json.dumps(json.load(sys.stdin),separators=(',',':')))" < file.json
Related Tools
Why Minify JSON?
Faster API Responses
Smaller JSON payloads mean less data transferred over the wire. On mobile networks or high-traffic APIs, this translates directly to faster page loads.
Lower Bandwidth Costs
Cloud providers and CDNs charge for data egress. Minifying JSON responses — especially for high-volume endpoints — can meaningfully reduce your bill.
Embedded Configs
JSON embedded in source code, environment variables, or database columns should be minified to keep the payload compact and avoid accidental newlines.
Cache Efficiency
Smaller responses fit more easily in browser caches, CDN edge caches, and in-memory caches like Redis, making cache hits more effective.
Minify JSON in Code
// JavaScript — parse then re-serialize without indent
const minified = JSON.stringify(JSON.parse(formatted));
// Or directly from an object
const minified = JSON.stringify(obj); // no third argument = minified
// Python
import json
minified = json.dumps(obj, separators=(",", ":")) # removes spaces after delimiters
// Go
import "encoding/json"
b, _ := json.Marshal(obj) // Marshal produces minified JSON by default
fmt.Println(string(b))
// Node.js CLI — minify a file
node -e "process.stdout.write(JSON.stringify(JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'))))" < input.jsonMinification vs. HTTP Compression
These are complementary, not competing techniques. Apply both for maximum benefit:
| Technique | How It Works | Typical Savings | Client Visible? |
|---|---|---|---|
| JSON Minification | Remove formatting whitespace | 5–40% | Yes (readable JSON) |
| gzip compression | Lempel-Ziv encoding at HTTP layer | 60–80% of remaining size | No (browser decompresses) |
| Brotli compression | Improved entropy coding | 5–20% better than gzip | No (browser decompresses) |
Frequently Asked Questions
What does minifying JSON do?▾
Minifying JSON removes all whitespace characters (spaces, tabs, newlines) that exist outside of string values. The resulting JSON is semantically identical to the original but takes fewer bytes to transmit and store.
When should I minify JSON?▾
Minify JSON for production API responses and configuration files that are transmitted over HTTP. Smaller payloads reduce bandwidth costs, improve mobile performance, and can lower CDN egress fees. For files you edit by hand (package.json, config files) keep them formatted.
How do I minify JSON in JavaScript?▾
Use JSON.stringify(JSON.parse(str)) — parsing then re-serialising without an indent argument produces minified output. Or call JSON.stringify(obj) directly on an already-parsed object.
How much does minification reduce JSON size?▾
It depends on how much whitespace was in the original. Heavily indented JSON with 4-space indentation and many nested levels can shrink by 20–40%. Already-compact JSON with shallow nesting may only shrink 5–10%. The tool on this page shows the exact byte savings.
Is minified JSON the same as compressed JSON?▾
No. Minification removes formatting whitespace, keeping the JSON fully human-readable if you know the structure. Compression (gzip, Brotli) is a binary encoding applied at the HTTP transport layer that further reduces size. For maximum efficiency, both minify and enable HTTP compression on your server.
Related JSON Tools
If jsondecode.com saved you time, share it with your team
Free forever. No ads. No sign-up. Help other developers find it.