Developer Tools

Minify CSS

This free Minify CSS tool strips comments, line breaks and the spaces around braces, colons, semicolons, commas and combinators, and drops the last semicolon in each block. Paste your CSS and the minified output appears instantly, with the character count before and after and the percentage saved. Everything runs in your browser, so nothing is uploaded.

Runs in your browser. Your files and text never leave your device - nothing is uploaded.

.container{max-width:1200px;margin:0 auto;padding:0 20px}.header{background:var(--brand-color);color:white}

Minify CSS Online and Shrink Your Stylesheets

The Tools Kit’s free Minify CSS tool compresses a stylesheet by stripping out comments, line breaks, indentation and the spaces around braces, colons, semicolons, commas and combinators. Paste your CSS and the minified version appears instantly, with the character count before and after and the percentage you saved.

Everything happens in your browser, so the CSS you paste is never uploaded. If your page also ships scripts, the JavaScript minifier does the same job for your JS files.

How to Minify CSS

  1. 1

    Paste your CSS

    Paste a stylesheet, a single rule or a block of CSS into the CSS Input box. The character count in its label updates as you type.

  2. 2

    Read the minified output

    The minified CSS appears on the right straight away; there is no button to press. Its label shows the new character count and how many percent smaller it is.

  3. 3

    Check the result

    Glance over the output, especially any calc() expressions that add values with a plus sign and any quoted strings, which this quick minifier also squeezes.

  4. 4

    Copy the minified CSS

    Click Copy Minified and paste the result into your production stylesheet, a style tag or your CMS.

There is no sign-up, no file upload and no limit on how often you use it.

What This CSS Minifier Removes

Browsers ignore comments and almost all whitespace in CSS, so those characters only add download weight. The minifier applies five steps in order:

  • Deletes every /* ... */ block comment.
  • Collapses each run of spaces, tabs and line breaks into a single space.
  • Removes the spaces on either side of { } : ; , > + and ~.
  • Drops the semicolon before each closing brace, since the last declaration in a block does not need one.
  • Trims any leading or trailing whitespace.

It does not rewrite values. Colors such as #ffffff, units on zero such as 0px and repeated shorthand values such as 16px 16px are left exactly as you wrote them, and duplicate or unused rules are not merged or removed. If you want shorter colors, pick the shortest equivalent format in the color picker before you paste.

What Minified CSS Looks Like

Minification is a purely textual change: the rules that reach the browser are the same, only the characters carrying them are fewer. Here is a commented, indented rule and what this tool turns it into.

Before — 95 characters

/* Card surface */
.card {
    margin:   0px;
    padding:  16px 16px;
    color:    #ffffff;
}

After — 49 characters (48% smaller)

.card{margin:0px;padding:16px 16px;color:#ffffff}

The comment, the line breaks, the indentation, the padding after each colon and the final semicolon are gone. A value-level optimizer such as cssnano or Lightning CSS could go a step further, to .card{margin:0;padding:16px;color:#fff} at 39 characters, by dropping the unit on zero, collapsing the repeated padding value and shortening the hex color. The sample already loaded in the tool, two rules with no comments, goes from 135 to 107 characters, a 21% saving. To turn character counts on large files into kilobytes, use the data storage converter.

Minify, gzip and Brotli are not the same thing

These three are often treated as alternatives. They are not - they stack, and using all three gives a smaller result than any one alone.

MinificationgzipBrotli
What it changesRewrites the source to be shorterCompresses the bytes in transitCompresses the bytes in transit
When it happensBuild time, onceEvery response, by the serverEvery response, by the server
What the browser receivesShorter sourceCompressed bytes, decompressed on arrivalCompressed bytes, decompressed on arrival
Helps parse timeYes - there is genuinely less to parseNo - the file is identical once decompressedNo - the file is identical once decompressed
Typical extra saving20–40% on unminified CSS70–80% on textRoughly 15–20% better than gzip

The order matters: minify first, then let the server compress. Minification is the only one of the three that reduces work for the browser’s parser, because gzip and Brotli hand over exactly the same css they were given once decompression finishes. Compression is usually already switched on at the CDN, which is why minifying is the step most likely to be missing.

When Minifying CSS Can Change Your Styles

This is a fast, text-based minifier rather than a full CSS parser, so it does not know whether a character sits inside a selector, a function or a quoted string. Most stylesheets come through unchanged in meaning, but check these three patterns:

  • Addition inside calc(). calc(1rem + 2px) becomes calc(1rem+2px), and browsers reject a plus sign in calc() without spaces around it. Subtraction is left alone, so calc(100% - 20px) is safe.
  • A space before a pseudo-class. .nav :hover (any hovered element inside .nav) becomes .nav:hover (the .nav element itself).
  • Quoted strings. Spacing inside content values and similar strings is collapsed too, and text that looks like a comment is removed.

Always keep your original, readable stylesheet as the file you edit. If you only have a minified file, the code beautifier restores line breaks and indentation so you can work on it again.

Why Minify CSS for Page Speed

External stylesheets are render-blocking: the browser waits for them to download and parse before it paints the page. A smaller CSS file arrives sooner and leaves less for the parser to read, which helps first paint, particularly on slow mobile connections. Minification is one part of trimming page weight; images are usually the bigger part, and the image compressor handles that side.

Generated CSS is a common source of padding. Code copied from the CSS gradient generator or the box shadow generator is nicely formatted for reading, and running it through the minifier before you inline it in a style tag keeps it compact.

Common uses

  • Compressing CSS for a small landing page or prototype that has no build step
  • Minifying critical CSS before inlining it in a style tag in the page head
  • Pasting a compact stylesheet into a CMS, email template or theme settings field
  • Estimating how much a stylesheet will shrink before adding a minification step to a build
  • Stripping comments from CSS before sharing it publicly

For formatters, encoders and other utilities, browse all developer tools.

Related developer tools

CSS minification terms explained

TermWhat it means here
MinificationRewriting source code to use fewer characters without changing what it does
WhitespaceSpaces, tabs and line breaks; browsers ignore most of it in CSS, so it can be removed or collapsed
Block commentText between /* and */; browsers skip it entirely, so it is safe to delete from production CSS
CombinatorThe >, +, ~ or space between selectors that sets how elements relate; the space (descendant) combinator is meaningful
Render-blocking resourceA file the browser must download and parse before it paints the page; external stylesheets are render-blocking by default
Source mapA file that maps minified code back to the original lines so browser dev tools can show readable source

Frequently Asked Questions

Reviewed by Raja Jahangir · Last reviewed: October 7, 2026

What does minifying CSS do?

Minifying CSS removes comments, line breaks, indentation and other unneeded whitespace without changing how the stylesheet behaves, often cutting 20-40% of an unminified file before gzip. Smaller CSS means less to download and parse, which helps render-blocking stylesheets load and first paint happen sooner.

Is minification the same as gzip?

No. Minification rewrites the source to be shorter, and gzip or Brotli compresses whatever bytes are then sent. They stack: minify first, compress in transit, and the total saving is larger than either alone. Minified files also parse faster in the browser, which compression alone does not help.

Sources and standards