🗜️ CSS Minifier

CSS Minifier - Strip comments and redundant whitespace to shrink CSS for faster loads, preserving semantics. Free, browser-only.

📐 工作原理与说明
依次执行:删除块注释;把连续空白压缩为单个空格;去掉花括号、冒号、分号、逗号、大于号这些符号两侧的空白;再去掉右花括号之前多余的分号。最终得到压缩后的 CSS
压缩 CSS 以减小文件体积。
  • 手段:去注释与空白、删除冗余分号、把 0px 简写为 0、缩进颜色值。
  • 合并:可合并等价声明与简写属性(如 margin 四值合并)进一步减小体积。
  • 风险:过度合并可能改变层叠与优先级,压缩后必须做视觉回归。
  • 建议:集成进构建流程并产出 source map,便于线上问题定位。

Formula & Standard References

Item Formula / Note Source / Standard
Whitespace remove redundant whitespace while keeping selector separation CSS Syntax Module Level 3
Comments block comments are removable; keep license headers CSS Syntax Module Level 3
Safety boundary preserve spaces inside calc() and custom properties CSS Values and Units Level 4
⚠️ 使用说明与注意事项

📋 说明

压缩后请本地预览效果是否一致;涉及 content 伪元素里特殊空格时,过度去空白可能需谨慎。本工具保留声明间必要空格。