CSS 压缩工具 CSS Minifier
将 CSS 代码压缩为更小体积:去掉注释、无意义空白,并尽量缩短符号周围的间隔,从而提升网页加载速度与缓存命中效率。
Minify CSS by removing comments and unnecessary whitespace to reduce file size and improve loading performance.
1. 输入参数 · Input
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.
