How to Minify CSS Text
Paste supported CSS text into the CSS Minifier and run the action to get a more compact version with block comments and selected spacing removed. Then compare the transformed text with its reported length difference and savings percentage.
What CSS minification changes
CSS minification turns supported stylesheet text into a more compact text form. This can make formatting changes easier to review when comments, extra spacing, or punctuation spacing add characters that you do not need in the shorter version. The tool removes block comments, adjusts selected whitespace, tightens spacing around specified punctuation, and removes a semicolon immediately before a closing brace. It is useful when you want to compare the original stylesheet with a concise transformed result, while keeping the source available for maintenance.
Steps for minifying CSS text
- Open the CSS Minifier and locate its CSS text input.
- Paste the stylesheet text into the input area. The field is optional, so leaving it empty is also a supported action, although it will produce an empty result.
- Run the minification action after checking that the text you want to transform is in the input.
- Read the resulting CSS text and compare its structure with the source. Block comments should be absent, spacing around braces, semicolons, colons, and commas should be tightened, and a semicolon immediately before a closing brace should no longer appear.
- Review the reported figures for the input length, transformed length, difference between those lengths, and savings percentage. The figures give you a way to assess the amount of text removed rather than relying only on visual appearance.
- Keep the original stylesheet separately if its comments or presentation spacing help people maintain it later. Then inspect the compact text for the parts relevant to your use before adopting it.
How to interpret the output
Read the transformed text as the outcome of selected text substitutions, not as a general diagnosis of the stylesheet. Whitespace around braces, semicolons, colons, and commas is removed; consecutive whitespace left elsewhere is collapsed to single spaces; leading and trailing whitespace is trimmed. The final pass removes a semicolon directly before a closing brace. For non-blank input, the displayed length difference shows how many characters separate the input and transformed strings, while the savings percentage expresses that reduction and is rounded to one decimal place. An empty or whitespace-only input follows a different path: it returns an empty output with zero original and transformed sizes. If the result needs to be assessed beyond these listed changes, review the CSS separately rather than treating the compact text as proof of parsing or validation.
Worked example
A developer wants to review a shorter form of a stylesheet containing a block comment and spaced declarations such as .card { color: red; margin: 0 1rem; }.
Use the sample stylesheet as the input, run the minification action, and compare the returned text with the source while checking the accompanying size figures.
The returned text retains the selector and declarations, omits the block comment, tightens spacing around the listed punctuation, and removes the semicolon immediately before the closing brace. Because the input is non-blank, the result also includes input length, transformed length, their difference, and a one-decimal savings percentage.
Limitations
- The reviewed behavior covers listed text substitutions and does not establish full CSS parsing, validation, standards compliance, semantic preservation, or support for every CSS construct.
Common errors
- An empty result can follow from an empty or whitespace-only field; paste the intended stylesheet text into the optional input and run the action again.
FAQ
Does the CSS Minifier remove comments?
For supported CSS text, block comments are removed before the remaining listed transformations are applied. Review the returned text when you need to confirm that comment content is absent from the transformed result.
Which whitespace changes does it make?
The transformation removes whitespace around braces, semicolons, colons, and commas, then reduces other consecutive whitespace to single spaces and trims whitespace at both ends of the text.
What size information appears after minification?
For non-blank input, the result reports the input length, transformed length, their difference, and savings percentage rounded to one decimal place. Blank or whitespace-only input instead returns empty output with zero sizes.