CSS minifier: minify, format and inline CSS into HTML

Use this CSS minifier to shrink a stylesheet, format it for reading, or inline it into style attributes for email newsletters. Comments, whitespace and needless zeros disappear without changing the effect. Syntax errors name the line, and your code stays in the browser.

Source: W3C CSS Syntax Module Level 3 (Tokenisierung, Kommentare, Zeichenketten, At-Regeln). Updated: .

My ToolboxYour inputs are saved in this browser only.

The code is processed in your browser only. In inline mode, paste a complete HTML document or a fragment containing <style>.

Your text stays in your browser – it is not sent, not stored and not added to the address bar.

Treated like one more style block at the end, for example from a separate CSS file.

Result

Result
.button{color:#fff;background:#05a;margin:0 auto;padding:.5em 1em}.button:hover{background:#037}@media (max-width:600px){.button{padding:.25em}}
Size
214 → 144 characters (33% smaller).
Removed: 1 comments, 0 empty rules. Comments starting with /*! are kept.

How it is calculated

This tool offers three things for stylesheets: minify for small files, format for readable code and inline for HTML email, where some programs ignore or trim style blocks.

Minify CSS

  1. Choose “Minify” and paste your CSS.
  2. Copy the result or download it as style.min.css. Below you see how much smaller the file became.

Only transformations that do not change the effect are applied: comments (except /*! … */) and whitespace go, so does the last semicolon before }, 0.50em becomes .5em, #aabbcc becomes #abc and 0px becomes 0. Zeros with a unit stay where they are needed: in calc(), min(), max(), clamp(), in the flex shorthand, for time, angle and percentage values and in custom properties. Strings and url() are left unchanged.

Format CSS

Compressed CSS becomes readable code: one declaration per line, selector lists line by line, indented blocks and a blank line between rules. Comments are kept.

Inline CSS into HTML

Paste an HTML document with a style block. For every element the matching rules are evaluated, sorted by specificity and order, and written into the style attribute. An existing style attribute beats normal rules, and !important beats everything. What cannot be written into an element, such as :hover, pseudo-elements, @media and @font-face, stays in a style block.

Good to know

Your code stays in your browser and is neither sent nor stored.

Frequently asked questions

How can I minify CSS?

Choose the “Minify” mode and paste the CSS. Comments, whitespace and needless zeros are removed, and the result can be copied or downloaded as a file.

Does minifying change how the page looks?

No, it only applies safe transformations. Zeros with a unit stay in calc() and the flex shorthand, for example, because they are needed there. Strings and url() are untouched.

What is CSS inlining for?

Some email programs ignore style blocks completely or partly. Inlining writes each rule into the element as a style attribute so the formatting arrives.

What happens to :hover and @media when inlining?

They cannot be written into an element and therefore stay in a style block in the head. Programs that support them still apply them.

How does the tool resolve conflicting rules?

By the CSS cascade: !important first, then higher specificity, and for a tie the later rule. An existing style attribute counts like a selector with the highest specificity.

Is my code uploaded?

No. Everything runs in your browser; the code is not sent, not stored and not written to the address bar.

Sources and legal basis

As of: · Editorial policy

Related tools