CSS Tools
Tools for stylesheets: format CSS for review and maintenance, or minify it to reduce file size for production.
Popular CSS Tools
All CSS Tools (2)
About CSS
The CSS Beautifier uses the open-source Prettier formatter with its CSS parser: one declaration per line, consistent spacing and two-space indentation. The CSS minifier removes comments and unnecessary whitespace and drops the last semicolon in each block. It does not rename, merge or reorder rules and does not rewrite values, so 0px and #ffffff stay as written.
Minifying removes only what a browser ignores, with two exceptions that the Minify CSS page describes: a space before a colon in a selector, and runs of spaces inside a quoted string. Serving the stylesheet with gzip or Brotli compression reduces its size further, whether or not it is minified.
Which tool to use
Use the CSS Beautifier to make a stylesheet readable. It parses the CSS, so a missing brace is reported with its line and column, which also makes it a quick syntax check. Minify CSS works on the text without parsing it and is meant for plain CSS that you have already checked. SCSS and LESS sources go to the SCSS Formatter and the LESS Formatter, which understand variables, nesting and mixins. Those two formats cannot be minified here: they have to be compiled to CSS by their own compiler first.
Worked example: Formatting vs minifying a responsive card stylesheet
Suppose you are auditing a 420-byte component stylesheet before deployment:
/* Primary card layout */
.product-card {
display: flex;
flex-direction: column;
padding: 1.25rem 1.5rem;
background-color: #ffffff;
border: 1px solid #e2e8f0;
border-radius: 0.75rem;
}
- In the CSS Beautifier: Indentation is normalized to 2 spaces (or 4 spaces), every property-value pair is placed on its own line with a trailing semicolon, and selector lists are spaced consistently for git diffs.
- In the Minify CSS tool: Comments (
/* Primary card layout */), newlines, and spaces after colons and braces are stripped, producing the 135-byte single-line output:.product-card{display:flex;flex-direction:column;padding:1.25rem 1.5rem;background-color:#ffffff;border:1px solid #e2e8f0;border-radius:0.75rem}(a 67.8% reduction before Gzip/Brotli).
Limits and what this tool cannot do
- Does not compile SCSS/LESS variables or mixins to plain CSS: While we offer dedicated SCSS and LESS formatters to indent preprocessor code, these browser tools format or minify syntax—they do not compile
$variablesor@mixinblocks into browser-ready CSS. - No dead-CSS purging (PurgeCSS) or vendor prefixing (Autoprefixer): The tools do not scan your HTML files to strip unused classes or inject
-webkit-vendor prefixes.
Frequently asked questions
How much smaller does minified CSS get?
By the size of its comments and of the whitespace between tokens, so a heavily commented, indented stylesheet shrinks the most. Compression on the server reduces the size further.
Does the minifier change selectors or values?
Values and rule order are unchanged. Selectors are unchanged too, except that a space before a colon is removed, so ".menu :hover" becomes ".menu:hover". Write ".menu *:hover" to keep the descendant meaning.
Can I format SCSS or LESS here?
Use the SCSS Formatter or LESS Formatter, which use the matching Prettier parsers.
Why did removing a space inside calc(100% - 20px) break my CSS?
According to the CSS Values and Units specification, the + and - operators inside calc() must be surrounded by whitespace so the parser can distinguish calc(100% - 20px) from a negative token -20px. Our CSS minifier preserves required spaces inside calc().
Common use cases
- Reading a minified stylesheet from a third-party site
- Tidying CSS before a code review
- Reducing the size of inline critical CSS
- Finding the unclosed brace in a stylesheet that stops applying half-way down
Example
.card {
padding: 16px;
border-radius: 8px;
}Formatted CSS: one declaration per line.