JSON Minifier
Minify and compact formatted JSON by stripping all non-essential whitespace, line breaks, and indentation. Shows the exact percentage of file size reduction achieved for payload optimisation.
JSON Minifier & Compact Formatter
Strip all whitespace, line breaks, and indentation from JSON to produce a single-line payload. Shows exact size reduction.
How to Use the JSON Minifier and Compact Formatter
A mobile app developer receives a 50 KB prettified JSON response from a REST API and needs to reduce bandwidth consumption on cellular networks. Paste the formatted JSON into the input panel and click Minify. The tool strips all whitespace, line breaks, and indentation, producing a single-line payload. The reduction badge shows that the payload shrank from 50 KB to 15 KB, a 70 percent reduction. Copy the minified output and use it in the mobile app codebase to reduce data transfer and improve load times.
A backend developer prepares API responses for a bandwidth-constrained IoT application. Paste the prettified JSON response, click Minify, and review the reduction badge. The exact byte count and percentage savings help determine whether the payload fits within the device transmission limits. The minified output is safe to embed directly in HTTP responses because it is semantically identical to the prettified version.
A DevOps engineer managing hundreds of Kubernetes ConfigMap JSON files wants to minimise storage on the Git server. Paste each file, click Minify, and review the reduction badge. The savings compound across large fleets of microservice configurations, reducing repository size and clone times. The minified JSON remains valid and parseable by any JSON consumer.
An observability engineer minifies JSON log entries before ingestion into a log aggregator to reduce storage costs and improve throughput. Paste a sample log entry, click Minify, and review the reduction badge to estimate savings at scale. The tool helps determine whether minification provides meaningful compression benefit for different log verbosity levels and payload structures.
A consultant needs to email a large JSON data export to a client but the file exceeds the 25 MB attachment limit. Paste the JSON, click Minify, and check whether the reduced size fits within the limit. The reduction badge shows the exact byte savings, helping you decide whether minification alone is sufficient or if you need to split the file into multiple attachments.
Related tools
How the JSON Minifier Works
The minifier takes prettified JSON with indentation, line breaks, and spacing, and strips it down to a single continuous line. It does this by parsing the input with JSON.parse() to validate the structure, then re-serialising it with JSON.stringify() and no indentation argument. This round-trip guarantees the output is valid JSON while removing every byte of non-essential whitespace.
Why Round-Trip Parsing Is Safer Than Regex
A naive find-and-replace approach that strips spaces and newlines would break string values containing spaces. The round-trip approach avoids this entirely: JSON.parse() correctly distinguishes structural whitespace from string content, so only formatting characters are removed. Strings like "hello world" or "line one\nline two" are preserved exactly as they appear in the original data.
Accurate Byte-Size Calculation
The reduction badge uses TextEncoder.encode() with UTF-8 encoding to count bytes rather than characters. This matters because multi-byte Unicode characters like emoji or accented letters take 2-4 bytes in UTF-8 but only count as one character in string.length. The percentage is calculated as (original bytes - minified bytes) / original bytes * 100, giving you a precise measure of how much bandwidth you save.
Frequently Asked Questions
Does minification change any of the actual data?
No. The tool uses JSON.parse followed by JSON.stringify, which guarantees the parsed data is identical before and after. String values like "hello world" retain their spaces, numbers keep their precision, and booleans stay true or false. The only thing removed is formatting whitespace outside of string literals.
How much size reduction should I expect?
It depends on how heavily your JSON is indented. Deeply nested structures with 4-space indentation and long property names typically see 40-70% reduction. Already-minified JSON with minimal whitespace saves under 5%. The reduction badge shows the exact byte count and percentage for every input, so you can immediately see whether minification is worth the effort for your specific payload.
Why not just use a text editor to remove spaces?
Find-and-replace whitespace removal would break string values that contain spaces. For example, a JSON field with the value "New York" would become "NewYork" if you naively stripped all spaces. The parse-and-serialise approach is the only safe method because the parser knows the difference between structural whitespace and content inside quoted strings.
Is the minified output always valid JSON?
Yes. Because the tool first parses the input to validate it, then re-serialises with no indentation, the output is guaranteed to be valid RFC 8259 JSON. If the original input had syntax errors, the tool reports them before producing any output. The minified result can be used anywhere standard JSON is accepted.
What happens to values like NaN or Infinity?
JavaScript values like NaN and Infinity are not valid JSON per the specification. When JSON.stringify encounters them, it converts them to null. If your data contains these values, the minified output may differ from the original. Review the output after minification to confirm the null substitution is acceptable for your use case.