How to Minify JSON
Submit valid JSON text as a string to receive its compact serialized form without added spaces after commas or colons. Empty or whitespace-only input is accepted through a separate path and returns an empty result with zero measurements.
What compact JSON does
JSON minification is useful when readable formatting makes a JSON value longer than necessary for a request body, configuration entry, or data exchange. JSON Minifier accepts optional text and handles it as JSON, rather than merely deleting visible whitespace. The submitted value must therefore be parsed before compact text can be produced.
Readable JSON often includes indentation and line breaks so people can inspect its structure. Compact serialization removes added spaces after commas and colons while retaining JSON text for a destination that expects that format. Keep a formatted source available when later editing or review will matter.
Process JSON from input to result
-
Put the JSON text into the input control as a string. Include the JSON value itself without notes before or after it, and check that property names and string values use double quotation marks.
-
Inspect the source for syntax problems, such as a missing comma, an unmatched bracket, or characters outside the value. For non-whitespace text, check the UTF-8 size as well; the applicable ceiling is 1,000,000 bytes.
-
Start the operation after checking the input. Valid, non-whitespace text within that UTF-8 limit is parsed and serialized as compact JSON, with no added spaces after commas or colons.
-
Examine the returned text and its measurements before using the result elsewhere. Empty or whitespace-only input follows a separate successful path and returns an empty result rather than compacted content.
-
When processing is unsuccessful, use the supplied result details to choose the correction. Invalid nonempty JSON includes a detected line and column, while a non-string value is rejected. Text beyond the UTF-8 limit is rejected before parsing, so syntax edits do not resolve that size condition.
-
Compare the compact text with the readable source when checking the outcome. Retain the readable version for maintenance, and confirm that the receiving field expects JSON text before inserting the returned value.
Interpret the returned result
For a successful nonempty submission, the result includes compacted JSON text together with input and output size measurements. Those figures count characters, whereas the acceptance ceiling is calculated from UTF-8 bytes, so the displayed sizes do not determine whether a larger submission meets the input condition.
Savings cannot be reported below zero, and the percentage is rounded to one decimal place. A source whose compact serialization has the same character count can therefore show no savings instead of a negative figure.
Non-ASCII characters are not forced into ASCII escape sequences during serialization. This describes the returned text format; it does not remove the requirement for valid JSON input.
An unsuccessful result indicates that the submitted value did not meet a processing condition. Invalid nonempty JSON supplies a line and column location, a non-string input is rejected, and oversized non-whitespace text is stopped before parsing. Empty or whitespace-only text is the successful exception, producing an empty result with zero size and savings measurements.
Worked example
A developer needs a compact representation of a small profile object for a web request.
Paste {"name": "Ada", "skills": ["JS", "CSS"]} with its formatting spaces, then start processing.
The result should show successful compact JSON text with input size, output size, and savings measurements.
Limitations
- Oversized non-whitespace text, non-string input, and nonempty invalid JSON do not produce a successful compacted result.
Common errors
- Single-quoted property names or a missing comma make nonempty JSON invalid; use the reported line and column to locate the syntax issue, revise the string, and submit it again.
FAQ
What does a JSON minifier do?
When the text is valid, non-whitespace JSON within 1,000,000 UTF-8 bytes, the tool parses it and returns compact JSON text without added spaces after commas or colons.
What happens if my JSON is invalid?
If nonempty JSON is invalid, processing is unsuccessful and the result includes its detected line and column location. Correct the source near that position before submitting the string again.
What is the input limit?
Whitespace-only text is handled successfully as empty input and returns zero size and savings measurements. Non-whitespace text must stay within 1,000,000 UTF-8 bytes.