JSON Minifier
JSON ToolsCompact JSON by removing whitespace — reduce file size by up to 80%. Free, private — all processing in your browser.
The JSON Minifier removes all unnecessary whitespace (spaces, tabs, newlines) from JSON while keeping the data structurally identical. The result is the most compact valid JSON representation — typically 60-80% smaller than pretty-printed JSON. Minification is lossless — your data is byte-identical after minify then un-minify. Use it to reduce API payload size, shrink webhook deliveries, optimize network transmission, and minimize storage for JSON files in databases and caches.
Minification is particularly valuable for high-throughput APIs — a 500 KB minified payload uses less bandwidth than a 2 MB pretty-printed payload, loads faster on mobile connections, fits better in HTTP response headers, and reduces CDN costs at scale. Combined with gzip/brotli compression at the HTTP layer, minified JSON can be 90%+ smaller than source. This minifier also handles edge cases: preserves whitespace inside string values, correctly handles escape sequences, and produces output that validates identically to the input.
JSON Minifier — key features
Lossless whitespace removal
Data structure preserved exactly. Minified JSON parses to the same object as original pretty-printed.
Size comparison
Shows before/after size in bytes, KB, MB. Shows percentage savings. See exactly how much you saved.
Copy or download
Minified output ready to paste into code, HTTP response, storage. Or download as .min.json.
Preserves escape sequences
String contents — escaped quotes, backslashes, Unicode escapes, whitespace inside strings — all preserved exactly.
Reverse-compatible
Minified JSON is standard JSON. Any parser (JavaScript, Python, Go, etc.) reads it identically to the pretty-printed source.
Combined with gzip
Shows estimated size after gzip compression (typical HTTP flow). Minify + gzip = maximum savings.
Handles large payloads
Multi-megabyte JSON processes instantly in browser. No server round trip.
100% client-side
Your JSON (possibly containing API keys, tokens, user data) never leaves your device.
How to use the JSON Minifier
- 1
Paste pretty-printed JSON
Drop JSON from a formatter, API tool, or manual editing. Can be pretty-printed, minified, or somewhere in between.
- 2
Click Minify
Output is compacted JSON on a single line (or as short as possible). All whitespace removed.
- 3
Review size savings
Tool shows original vs minified size and the percentage saved. Typically 60-80% reduction.
- 4
Copy or download
Copy the minified output for your HTTP response, database, or cache entry. Or download as .min.json.
Common use cases for the JSON Minifier
API optimization
- →Reduce API response payload size: Minified JSON responses transfer faster, use less bandwidth, improve mobile performance.
- →Shrink webhook payloads: Sent at high volume — every KB counts. Minified webhooks reduce bandwidth costs at scale.
- →Streamline GraphQL responses: GraphQL responses are JSON — minified = faster queries for mobile clients.
- →Optimize SSE and long-poll streams: Server-sent events stream JSON updates. Minified events reduce data usage.
Storage and caching
- →JSON in databases: PostgreSQL, MySQL, MongoDB store JSON — minified saves disk space and index size.
- →Redis/Memcached values: In-memory caches benefit from smaller values — more cached items per GB RAM.
- →JSON log files: Structured logs in JSON — minified saves 70%+ disk space over time.
- →Browser localStorage: 5-10 MB limit per domain. Minified JSON lets you store more.
Transmission and embedding
- →JSON in URL parameters: Embed JSON in query strings (base64-encoded typically). Minified + URL-encoded = shortest URL.
- →HTTP headers: Some headers carry JSON (e.g., JWT payload). Minified JSON fits in header size limits.
- →Data URIs: Embed JSON in data URLs. Minified = shortest URL.
- →Configuration in HTML attributes: Data attributes carry JSON — minified keeps HTML compact.
Build pipelines
- →Static site JSON data: Hugo/Jekyll/Astro embed JSON data files. Minified ships smaller bundles.
- →Bundled API mocks: Mock data files in JavaScript bundles — minify to reduce bundle size.
- →Translations (i18n): Translation JSON files can be huge. Minified + chunked = faster page loads.
JSON Minifier — examples
Simple minification
Remove pretty-print whitespace.
{
"name": "Alice",
"email": "alice@example.com"
}{"name":"Alice","email":"alice@example.com"}
Size: 60 bytes to 44 bytes (27% reduction)Deeply nested object
Bigger savings with deep nesting.
Pretty 1.2 KB nested object
Minified 380 bytes Reduction: 68%
Array of objects
High minification ratio for repeated structures.
100 user objects (25 KB pretty)
Minified: 7.2 KB (71% smaller) After gzip: 1.8 KB (93% smaller vs original)
Preserves string whitespace
Whitespace inside strings is NOT removed.
{
"message": "Hello, world!\n\nParagraph 2."
}{"message":"Hello, world!\n\nParagraph 2."}
String contents (including newlines) preserved exactly.Reversible
Minified JSON pretty-prints back to original.
Minified input
Pretty printed output identical in data
Technical details
JSON minification is lossless — it removes whitespace that has no semantic meaning, but preserves everything else exactly.
What gets removed:
- Spaces outside string values (between colons and values, after commas, around brackets and braces)
- Newlines and indentation
- Tab characters
- Any whitespace that does not affect parsing
What is preserved:
- Whitespace inside string values (including spaces, newlines, tabs inside quotes)
- All structural characters: brackets, braces, commas, colons, quotes
- Number formatting exactly (3.14 stays as 3.14, not 3.140)
- Unicode escape sequences
- Property order
Size savings (typical examples):
| Pretty-printed | Minified | Savings |
|---|---|---|
| 4 KB | 800 B | 80% |
| 100 KB | 25 KB | 75% |
| 10 MB | 3 MB | 70% |
Ratios depend on indentation depth and key/value lengths. Deeply-nested JSON with short strings benefits most from minification.
Minification algorithm:
1. Parse input JSON (validates syntax at the same time).
2. Walk the parsed tree (objects, arrays, primitives).
3. Serialize with JSON.stringify(value) with no indent argument.
4. Result: exact same JSON data, no whitespace between tokens.
Combined with HTTP compression:
HTTP supports gzip and brotli compression automatically. Typical flow:
1. Server generates JSON (e.g., API response) — 200 KB pretty-printed.
2. Server minifies to 50 KB.
3. Server compresses with gzip to 8 KB (client supports Accept-Encoding gzip header).
4. Network transmits 8 KB instead of 200 KB — 25x reduction.
Should you minify in production?
- APIs: Yes — minified JSON + gzip is the smallest HTTP payload.
- Development: No — pretty-printed is easier to debug. Enable dev vs prod mode in your API.
- Storage: Yes for large databases, no for frequent editing.
- Cache: Minified + compressed for Redis, Memcached, CDN.
Minification vs compression:
- Minification: removes unnecessary whitespace (textual transformation).
- Compression: algorithmic (gzip, brotli) — typically 80-90% smaller.
- Use both: minification + compression produces the smallest delivery size.
Edge cases:
- Scientific notation: 1e10 preserved as 10000000000 or 1e10 depending on parser.
- Unicode escapes: backslash-u-00E9 preserved (could optimize to é saving 5 bytes per occurrence).
- Empty objects/arrays: {} and [] are already minimal.
- Numbers with trailing zeros: 3.10 may become 3.1 depending on parser.
Common problems and solutions
⚠Minified JSON is unreadable
By design. Minify for production/storage/transmission; pretty-print for development and debugging. Many frameworks serve minified in prod and pretty in dev automatically.
⚠Some parsers require trailing newline
Strict parsers may expect final newline at end of file. Add it manually if needed — minified JSON without final newline is still valid JSON, just may not pass some linters.
⚠Double-minification
Minifying already-minified JSON does nothing useful — it is already minimal. Avoid running in build pipelines twice.
⚠Gzip savings diminish for small files
For JSON under ~1 KB, gzip overhead may exceed savings. Minification itself is fine, but do not add gzip for tiny payloads.
⚠Whitespace inside strings preserved
String values keep all their whitespace. If your strings contain formatted text, minification will not shrink them. Only whitespace between JSON tokens is removed.
⚠Number formatting differences
Some minifiers may reformat numbers: 3.10 to 3.1, 1e2 to 100, 0.1 to .1. Check if your consumer is sensitive to these. This tool preserves original formatting.
⚠Minifying config files accidentally
Minify is for data transmission, not source code. Minifying your tsconfig.json makes it unreadable for teammates. Keep configs pretty-printed.
JSON Minifier — comparisons and alternatives
Minification vs Compression (gzip/brotli): Minification is textual — removes whitespace. Compression is algorithmic — reduces all redundancy. Use both: minify (70% reduction) then gzip (another 80% reduction). Combined: ~95% smaller than original pretty-printed JSON.
Minification vs format changes (msgpack, protobuf): For maximum size reduction, use binary formats like MessagePack or Protocol Buffers — 2-5x smaller than minified JSON. But they lose JSON universality (not human-readable, not parseable by standard JSON tools). Use for high-volume internal APIs; keep JSON for external-facing APIs.
JSON minification vs CSS/JS minification: Same concept, different targets. JSON minification is purely whitespace removal (no semantic rewriting). CSS minification also shortens property names, combines selectors, removes unused rules. JS minification renames variables, removes dead code, inlines functions.
JSON Minifier vs JSON Formatter: Minifier produces compact JSON; Formatter produces pretty-printed JSON. Opposite operations, lossless roundtrip. See our JSON Formatter.
Production server minification vs tool-based minification: Servers can minify JSON responses automatically (Express JSON.stringify with no indent, etc.). Tool-based minification is for one-off cases: inspect a response, reduce a static file, optimize stored data.
Frequently asked questions about the JSON Minifier
▶What is JSON minification?
Removing all non-essential whitespace from JSON to produce the most compact representation. The data stays identical — only whitespace between structural elements is removed. A 1 KB pretty-printed JSON typically becomes 300-400 bytes minified.
▶Is minification lossless?
Yes. Data structure is preserved exactly. Minified JSON parses to the same JavaScript object as the pretty-printed source. You can round-trip: pretty-print then minify then pretty-print and get the original back.
▶How much can I save by minifying?
Typically 60-80% reduction from pretty-printed JSON. Deeply-nested JSON with short string values saves more. Flat JSON with long string values saves less. Combined with gzip compression, total savings reach 90-95%.
▶When should I minify?
APIs in production (every response). Data stored at scale (databases, caches, logs). JSON embedded in URLs, headers, attributes. JSON bundled into JavaScript (reduce bundle size). Mobile clients (faster on slow connections). Avoid minifying during development — pretty JSON is easier to debug.
▶Is minified JSON still valid JSON?
Yes. Minified JSON is standard JSON — every JSON parser reads it identically. No special tool needed to consume minified JSON.
▶Is my JSON safe here?
Yes. Minification happens entirely in your browser. Your JSON (which may contain API keys, user data, tokens) never uploads anywhere. Verify with DevTools Network tab.
▶Why are my savings not as high as expected?
Two common reasons: (1) Long string values — whitespace inside strings is preserved (text content, not formatting). (2) Already semi-minified — if your source already has minimal whitespace, additional minification will not help much. Compare bytes before and after.
▶Should I also use gzip?
Yes, if your server and client both support it (virtually all modern ones do). Minification + gzip = maximum savings. HTTP automatically negotiates compression via Accept-Encoding header. Configure your server to enable gzip/brotli.
▶Can I minify JSON in JavaScript?
Yes: JSON.stringify(yourObject) produces minified JSON (no indent argument). JSON.stringify(yourObject, null, 2) produces pretty-printed with 2-space indent. JavaScript handles this natively.
▶What about JSON5 or JSONC minification?
Standard JSON minifiers do not handle JSON5 (comments, trailing commas) or JSONC. Convert to strict JSON first (strip comments and trailing commas), then minify. Or use JSON5-aware tools.
Additional resources
- HTTP Compression (MDN) — How gzip and brotli work in HTTP.
- JSON Specification RFC 8259 — Official JSON standard — whitespace handling details.
- JSON.stringify — MDN — JavaScript built-in JSON serializer (no indent = minified).
- MessagePack — Binary JSON alternative for maximum size reduction.
- Brotli Compression — Modern HTTP compression — smaller than gzip.
Related tools
All JSON ToolsBase64 Encoder/Decoder
Encode and decode Base64 strings, files, and images instantly
CSS Minifier
Compress CSS to minimum size — remove whitespace, comments, shorten values
HTML Minifier
Compress HTML by removing whitespace, comments, optional tags — 20-40% smaller
JavaScript Minifier
Compress JavaScript for production — Terser-style minification, 30-50% smaller
JSON Formatter
Format, validate, and beautify JSON instantly in your browser
JSON to CSV
Flatten nested JSON into CSV rows — ready for Excel, Google Sheets, analysis
Learn more
Explore more tools
200+ free tools that run in your browser.
Browse all tools →