CSS Minifier|CSS 压缩工具

CSS Minifier | CSS 压缩工具

CSS 压缩工具 CSS Minifier

将 CSS 代码压缩为更小体积:去掉注释、无意义空白,并尽量缩短符号周围的间隔,从而提升网页加载速度与缓存命中效率。
Minify CSS by removing comments and unnecessary whitespace to reduce file size and improve loading performance.

1. 输入参数 · Input
建议 · Tips:
1) 输入越“真实”,压缩收益越直观(含注释、缩进、空行的 CSS)。
2) 若你的 CSS 中包含需要保留的特殊注释(例如许可证注释),可开启“保留 /*! */ 注释”。
3) 该工具为前端纯本地处理,内容不会上传服务器。

Notes:
1) The more formatting and comments your CSS has, the bigger the minify gain you’ll see.
2) If you need to keep license banners, enable “Keep /*! */ comments”.
3) Everything runs locally in your browser; nothing is uploaded.

“保留 /*! */”常用于保留版权/许可证 Banner(例如:/*! License ... */)。
“去末尾分号”仅会尝试移除 { ...; } 中最后一个多余分号(有些团队规范喜欢保留,默认不启用)。
Keeping /*! ... */ is common for license banners. Dropping the last semicolon is optional and disabled by default.

关于兼容性 · Compatibility:
该压缩器以“安全压缩”为目标:主要做注释与空白处理,不做激进重写(例如:颜色缩写、0 值合并、选择器重排)。
This minifier focuses on safe operations (comments/whitespace) and avoids aggressive rewrites (color shortening, advanced transforms, selector reordering).

适用场景 · Use cases:
• 粘贴到 WordPress / Discuz 自定义 CSS 前压缩
• 生产环境上线前的体积优化(配合 gzip/brotli 更佳)
• 将多段 CSS 合并后再压缩,减少传输与缓存成本
3. 使用说明 · Notes
  • 基本使用 · Basic workflow:
    将你的 CSS 粘贴到“原始 CSS”输入框 → 勾选需要的压缩选项 → 点击「压缩 CSS」。压缩后的内容会显示在“压缩后 CSS”区域。
    Paste your CSS into “Original CSS” → choose options → click “Minify”. The minified CSS will appear in the output area.
  • 复制与替换 · Copy & replace:
    点击「复制结果」即可把压缩后的 CSS 复制到剪贴板;点击「输出覆盖输入」可把输出直接替换回输入框,方便你继续二次处理(例如:把多段 CSS 逐段压缩合并)。
    Use “Copy Output” to copy to clipboard. “Replace Input” overwrites the input with the output, useful for iterative cleanup/merging.
  • 关于注释 · About comments:
    默认会移除普通注释 /* ... */,但会保留以 /*! ... */ 开头的 Banner 注释(常用于许可证/版权声明)。若你不需要保留,可取消勾选“保留 /*! */”。
    By default it removes regular /* ... */ comments but keeps /*! ... */ banners (commonly used for license notices).
  • 空白压缩原则 · Whitespace rules:
    工具会尽量删除与合并“不会改变语义”的空白:例如符号两侧的空格、换行、制表符;同时会尽量避免破坏字符串与 URL 中的内容。
    The tool removes whitespace that should not affect semantics (spaces/newlines around tokens) while trying to keep strings and URLs safe.
  • 与构建工具的关系 · Relation to build tools:
    如果你已经在用 Webpack/Vite/Rollup/PostCSS/CSO/CleanCSS 等构建链路,线上通常会自动压缩;本工具更适合:临时粘贴、快速检查、在 CMS 后台(WordPress/Discuz)手动维护 CSS 的场景。
    If you already have a build pipeline (Webpack/Vite/PostCSS/CleanCSS, etc.), minification is typically automated. This tool is ideal for quick manual use (CMS custom CSS, debugging, copy/paste).
  • 常见坑提醒 · Common pitfalls:
    1) 若 CSS 内包含“特殊黑科技 hack”,压缩前后最好在浏览器里对比效果;
    2) 如果你在注释中写了会被脚本读取的标记(极少见),移除注释会影响逻辑;
    3) 压缩能减少体积,但真正的“加载速度”还与 HTTP/2、缓存策略、CDN、gzip/brotli、首屏关键 CSS 等因素有关。
    If you rely on unusual hacks or comment-based markers, test before/after. Minification helps, but delivery (cache/CDN/compression) matters too.
  • 隐私与安全 · Privacy & security:
    本页面不联网、不上传内容;所有处理均在浏览器本地完成。你可以放心用于内部样式、商业项目 CSS、或包含敏感类名/路径的代码片段。
    Offline-only. Your CSS stays in your browser and is not sent anywhere.

免责声明:本工具仅对 CSS 做基础压缩(注释/空白处理)以降低体积,结果用于学习与工程辅助。 若用于生产环境,请结合你的发布流程与回归测试,确保浏览器兼容性与页面显示一致。
Disclaimer: This tool performs basic minification (comments/whitespace). For production use, please integrate it into your pipeline and run regression tests to ensure rendering consistency.