JSON Minifier
CodeMinify JSON by stripping all whitespace and formatting. Optionally sort keys alphabetically. Runs entirely in your browser — nothing is uploaded anywhere.
Reviewed by the thecalcu.com team · Last updated July 13, 2026
What is a JSON Min?
The JSON Minifier strips all non-essential whitespace from a JSON document, spaces, tabs, newlines, and carriage returns that are not part of a string value, producing the smallest valid JSON representation of the same data. It is the counterpart to the JSON Formatter: where the formatter makes JSON human-readable, the minifier makes it as compact as possible for transmission and storage.
JSON is a text-based format, and pretty-printed JSON is deliberately verbose. A response like:
{
"status": "ok",
"count": 3
}
becomes {"status":"ok","count":3} when minified, roughly 40% smaller. For large API responses with hundreds of fields and nested objects, the savings compound significantly, reducing payload size by 20–60% depending on the depth and variety of the data.
The JSON Minifier also includes an optional key-sorting step. Sorting object keys alphabetically produces a canonical form of the JSON, two documents with the same data but different key orders produce identical minified output, which is essential for caching, comparison, and deterministic signing.
All processing runs entirely in your browser using the built-in JSON.parse() and JSON.stringify() functions. Your JSON is never sent to a server or stored anywhere, safe for API tokens, credentials, database schemas, and internal configuration.
Why Use a JSON Minifier?
The primary reason to minify JSON is to reduce network payload size. REST APIs that return large collections, configuration endpoints, or search result sets can grow to hundreds of kilobytes when pretty-printed. A minified payload transmits faster and costs less in bandwidth, particularly relevant for mobile APIs, pay-per-GB cloud egress, and high-throughput services handling millions of requests per day.
A secondary use is deterministic output for caching and comparison. If two systems independently construct the same JSON object but in different key orders, a naive comparison fails even though the data is identical. Minifying with key sorting produces a canonical form that is identical in both cases.
JSON minification is also a prerequisite for some digital signatures and message authentication codes (HMACs), where the signing algorithm requires a canonical byte representation of the payload.
Who Should Use This Formatter?
API developers testing and optimising API responses will find the minifier useful for measuring the exact byte size of a payload and for stripping whitespace before embedding JSON in build artifacts or Docker image configurations.
Front-end engineers embedding JSON in JavaScript bundles, HTML <script> tags, or static configuration files should always use minified JSON to avoid shipping unnecessary whitespace to the client.
DevOps and platform engineers managing Kubernetes manifests, Terraform state files, or other infrastructure JSON need minified output when checking values into Git or diffing configurations between environments. The key-sort option makes those diffs more readable. Pair this with the JSON Formatter to switch between human-readable and compact forms during debugging.
Data engineers building ETL pipelines that exchange large JSON payloads between services benefit from minification at each pipeline stage to keep inter-service traffic lean.
What Insights Does the JSON Minifier Give You?
Seeing the byte size of the minified output (visible in the character count of the output box) gives a concrete measure of the true data size stripped of formatting overhead. Comparing the minified and pretty-printed sizes shows exactly how much whitespace your JSON contains, a useful diagnostic when optimising API responses.
The key-sorting option also reveals structural inconsistencies: if the same logical object appears with keys in different orders across two API calls, the minified key-sorted forms will be different even if the data is identical, which is a signal that key ordering is not enforced at the producer.
How to use this JSON Min calculator
- Paste your JSON into the Raw JSON box, this can be pretty-printed or already partially minified.
- Optionally enable Sort keys alphabetically to produce canonical, order-independent output.
- The Minified JSON output appears instantly and updates on every keystroke.
- If the input is invalid JSON, the output will show a parse error message with the position of the problem.
- Click Copy to copy the minified result to your clipboard.
Formula & Methodology
Minification uses two built-in JavaScript functions:js JSON.stringify(JSON.parse(input))JSON.parse()converts the input string into a JavaScript value tree, validating it in the process.JSON.stringify()serialises it back to a string with no indentation argument, which produces the most compact representation. When key sorting is enabled, a recursive pass sorts each object's keys alphabetically before stringification:js function sortKeys(val) { if (Array.isArray(val)) return val.map(sortKeys); if (val !== null && typeof val === 'object') { return Object.fromEntries( Object.keys(val).sort().map(k => [k, sortKeys(val[k])]) ); } return val; } JSON.stringify(sortKeys(JSON.parse(input)));Arrays are not reordered, only object keys are sorted. The sort is lexicographic (case-sensitive), which is the same order used by most diff and comparison tools. Before:json { "name": "thecalcu.com", "calculators": 134, "tags": ["finance", "tax", "math"] }After (minified, keys sorted):json {"calculators":134,"name":"thecalcu.com","tags":["finance","tax","math"]}
Frequently Asked Questions