webdev_css_minifier
Minify CSS by removing comments, collapsing whitespace, compressing colors, and shortening zero units. Reduces file size while preserving important declarations.
Instructions
CSS Minifier. Minify CSS by stripping comments and collapsing whitespace, and optionally compressing hex/named colors, shortening zero-value units, preserving !important, and tightening universal-selector combinators. Pass the stylesheet as the css parameter; each transform is an independent boolean toggle. Use webdev_code_formatter or webdev_css_beautifier to expand CSS for readability instead, webdev_sass_compiler to compile SCSS/SASS into CSS first, and webdev_html_minifier or webdev_js_minifier for standalone markup or scripts. Regex-based minifier, not a CSS parser, so unusual or malformed input may need review. Runs locally via a Node bridge: read-only, non-destructive, contacts no external service, and is rate-limited (60 requests/minute for anonymous callers). Returns the minified CSS plus original/minified byte sizes, byte savings, and compression ratio.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| css | Yes | CSS source to minify. Must not be blank; an empty value returns a 400 error. | |
| removeComments | No | Strip CSS comment blocks. | |
| removeWhitespace | No | Collapse whitespace and remove space around braces, colons, semicolons, and combinators. | |
| compressColors | No | Shorten 6-digit hex colors to 3 digits and replace common color names with shorter hex values. | |
| compressUnits | No | Drop leading zeros and remove units from zero values (for example 0px becomes 0). | |
| preserveImportant | No | Keep !important declarations intact during minification. | |
| optimizeSelectors | No | Tighten universal-selector combinators (for example a star then child combinator becomes just the child combinator). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| original | No | The submitted CSS, echoed back. | |
| minified | No | The minified CSS output. | |
| originalSize | No | Length of the original CSS in characters. | |
| minifiedSize | No | Length of the minified CSS in characters. | |
| compressionRatio | No | Percentage size reduction, rounded to two decimals (0 when input is empty). | |
| savings | No | Characters saved (originalSize minus minifiedSize). | |
| options | No | The effective options after defaults were applied. |