JSON Minifier
CodeMinify JSON by stripping all whitespace and formatting. Optionally sort keys alphabetically. Runs entirely in your browser — nothing is uploaded anywhere.
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.
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"]}