CSS Minify
Shrink CSS by removing comments and unneeded whitespace — conservatively, with nothing renamed or reordered.
Minified CSS is the same stylesheet with everything a browser does not need taken out: comments, newlines, indentation, the spaces around punctuation, and the semicolon after the last declaration in each block. The sample at the top — a comment plus one rule with spaced-out colons — is 70 characters as written and 41 minified, a saving of about 41%, and typical stylesheets land in the 20–50% range depending on how comment-heavy they are. This page’s minifier is deliberately conservative: it never renames classes, never merges two rules, never reorders declarations and never rewrites values (0px stays 0px), because those optimisations are where minifiers occasionally change what a stylesheet does.
Minifying runs in this browser only — your CSS is never uploaded, stored or put into a link. This is a conservative minifier: it removes comments and unneeded whitespace but never renames, merges or reorders anything, and it leaves the spaces inside calc() and around descendant selectors exactly as the rules require.
Quick answers
How do I minify CSS?
Remove comments and the whitespace browsers do not need: around braces, semicolons, commas and — inside declaration blocks — colons, plus the last semicolon of each block. “a { color : red ; } /*x*/” minifies to “a{color:red}”.
This minifier is conservative on purpose: strings are protected, calc() keeps its required operator spaces, and nothing is renamed, merged or reordered.
What is the difference between a conservative minifier and an optimising one?
A conservative minifier removes whitespace and comments only, so its output is provably the same stylesheet. An optimising minifier also merges rules, rewrites values and renames classes — smaller output, but each extra trick is a place behaviour can change.
For pasting into a page or checking a snippet, conservative is the right default; optimising belongs in a tested build pipeline.
How to use
- Paste your CSS into the top box.
- Read the minified result below and check the size line: characters before and after, and the percentage saved.
- Spot-check a string value and any calc() in the result — both are preserved exactly, by design.
- Copy the result into your build or your page. Keep the readable original as your source of truth — minified CSS is an output, not a working file.
About this tool
Three safety details are built in rather than left to luck. Quoted strings are protected before anything else happens, so a content value like "a /* b */" is never mistaken for a comment and its internal spaces survive. The spaces CSS actually requires are kept: around the + and − operators inside calc(), and before a colon in a selector such as a :hover, where removing the space would change the selector’s meaning (colon spacing is only stripped inside declaration blocks, where it is always safe). And because everything runs on your device, the un-minified original never leaves your hands.
Frequently asked questions
What exactly does this minifier remove?
Comments (/* … */), all runs of whitespace collapsed away around { } ; , and > combinators, the spaces around colons inside declaration blocks, spaces just inside parentheses, and the now-redundant semicolon before each closing brace. Values, selectors, rule order and declaration order are never touched.
Is the minified CSS guaranteed to behave identically?
It is written to: the transformations are the whitespace-level ones that cannot change meaning, strings are protected, and the two famous traps — calc() operator spaces and the descendant-selector space in a :hover — are explicitly preserved. As with any minifier, the honest routine is to minify a copy, not your only original, and to glance at the result before shipping it.
How much smaller will my CSS get?
Typically 20–50%. The worked example on this page goes from 70 to 41 characters (about 41%) because it is comment- and space-heavy; a stylesheet that is already compactly written may only save 15%. The result line always shows your real before/after numbers rather than a promise.
Does it also gzip or rename classes?
No. Renaming classes for size is a build-pipeline job that has to rewrite your HTML at the same time, and gzip is a server setting. This page does the text-level step only — the step you can verify by eye before and after.
First time embedding? Read the step-by-step guide →
More free tools
UUID Generator
Generate random v4 UUIDs in bulk.
JSON Formatter & Validator
Format, minify and validate JSON in one click.
What Is My IP
See your public IP address instantly. No sign-up, nothing stored.
Regex Tester
Test, check and validate regular expressions with live highlighting.
JWT Decoder
Decode a JWT token without the secret — see its header and payload.
SHA-256 Hash Generator
Generate SHA-256 / SHA-512 hashes instantly.