站点介绍

Inheriting an old project this January meant facing a stylesheet minified six years ago - one line, thirty thousand characters. Changing a responsive breakpoint required un-minifying it by hand first; that afternoon of toggling the blob back and forth in a formatter left me wanting one simple comfort: the rule count staying put after compression. This page is that afternoon's product: minify, beautify, comment toggle, rule counting, all present.
The scariest minifier failure is not failing to shrink - it is silently dropping rules. A selector that fails to parse, an unclosed block, an @media whose contents get swallowed: none of it shows to the naked eye after compression, and the broken site is what tells you.
This page puts the rule count in the status line: 47 rules before compressing, 47 after; switch to beautify and back, still 47. An unchanged number does not prove correctness, but a changed one proves a bug - and that one glance is worth it.
Minify strips comments by default - saving bytes is the point. Two exceptions: bang-prefixed /*! important comments survive by default (the copyright convention; deleting them can be a licensing problem), and a toggle keeps regular /* */ comments too when checked.
Beautify mode keeps every comment, indented with its rule. In team codebases comments are documentation - present when reading, out of the way when shipping. Two shapes, each doing its job.
No, and it will not pretend to. $variables, @mixin, nested selectors, .less mixins - that is preprocessor syntax; both browsers and this tool parse standard CSS, so those get treated as plain text or flagged with a warning. Compile your Sass to CSS first (a one-command sass file.scss job), then paste it here. This page's job is minifying and beautifying standard CSS.
By default yes - that is the point of minification, and every byte counts. Two exceptions: /*! bang-prefixed important comments */ (the copyright-notice convention) survive by default, and a "keep comments" toggle preserves regular /* */ comments too when checked. Beautify mode keeps every comment by default, indented along with its rule.
They warn, they do not block. Standard CSS allows the last declaration in a block to omit its semicolon (though appending another declaration later would break), so the tool warns which rule is missing one and processes the declaration anyway - more useful in practice than refusing. Minified output adds the semicolons back automatically, so later edits stay safe.
Yes. Rules inside @media (and block-level at-rules like @supports, @keyframes) indent one level deeper than the outer layer, and deeper nesting indents further - the hierarchy reads at a glance. The rule count does not change between minify and beautify: each selector-plus-declaration-block is one rule, and both modes count the same set. The status line shows rule count and byte savings so you can verify yourself.
No. Minification, beautification and checks all happen inside this device's browser - there is no upload endpoint and it works offline. Only preferences like indent width and the comment toggle live in this browser's localStorage; they do not follow you to another device, and "Clear my data" in the footer removes them.
中文版:https://www.9314.cn/tools/css-formatter/
评论列表 (0条)