Home › Developer Tools › CSS Minifier

CSS Minifier

Paste a stylesheet to strip comments, whitespace and redundant characters. The tool uses the csso optimizer when it can load it and a careful built-in minifier otherwise, and it always tells you which engine ran.

Last updated:

Original–
Minified–
Saved–
Advertisement

How to use the CSS Minifier

  1. Paste your CSS into the input box, or press Upload .css (dropping a file also works).
  2. Choose the engine: Auto uses csso when it can be loaded, otherwise the built-in minifier runs. The badge under the buttons always shows which engine was used.
  3. Decide on restructuring: with csso you can let it merge and reorder rules for the smallest output, or turn it off for a safer, order-preserving result.
  4. Press Minify CSS (the output also updates as you type) and check the bytes saved.
  5. Copy or Download the minified stylesheet and reference it in your site.

CSS minification rules with examples

RuleBeforeAfter
Remove comments (keep /*!)/* nav */ a{…}a{…}
Remove whitespace around { } : ; , > + ~.a > b , .c { color : red ; }.a>b,.c{color:red}
Drop the last semicolon{margin:0;padding:0;}{margin:0;padding:0}
Zero lengths need no unitmargin:0px 0emmargin:0 0
Shorter numbersopacity:0.50; line-height:1.0opacity:.5;line-height:1
Short hex colours#FFFFFF, #2F6B4F, #aabbccdd#fff, #2f6b4f, #abcd
Remove empty rules.unused { }(removed)
Keep meaningful spacesa :hover, calc(100% - 20px)(unchanged)

Two rules are deliberately left alone by the built-in engine: units on zero values inside functions such as calc(0px + 1em), where the unit is required, and time or percentage zeros like 0s and 0%, which are not interchangeable with a bare 0.

Built-in engine vs csso

Built-in minifiercsso 5.0.5
Works offlineYesNeeds the CDN once per visit
Whitespace, comments, semicolonsYesYes
Zero units, numbers, hex coloursYesYes, plus colour names (e.g. #f00 → red)
Merge duplicate selectors and declarationsNo (keeps your rule order)Yes, with restructuring on
Typical saving on hand-written CSS15–25%20–35%

Worked example

This 78-byte rule set:

.card > h2 ,
.card + .note {
  color : #2F6B4F ;
  margin : 0px auto 0.0px ;
}

becomes .card>h2,.card+.note{color:#2f6b4f;margin:0 auto 0}: 51 bytes, a saving of 27 bytes or about 35% (27 ÷ 78 × 100). Saved % is calculated as (original bytes − minified bytes) ÷ original bytes × 100, using UTF-8 byte sizes.

Frequently asked questions

What does a CSS minifier do?

It removes everything the browser does not need to apply your styles, such as comments, indentation, line breaks, the last semicolon in each rule and empty rules, and it writes values in their shortest form. The result renders exactly the same but downloads faster.

What is csso and what does restructuring mean?

csso (CSS Optimizer) is an open-source minifier that parses CSS into a syntax tree. With restructuring on, it also merges duplicate selectors and declarations and may move rules, which gives the smallest file. Turn restructuring off if your CSS relies on a very specific rule order.

Why did the built-in engine run instead of csso?

csso is loaded from a public CDN the first time you minify. If you are offline, a network filter blocks the CDN, or you chose “Built-in minifier only”, the tool uses its own minifier instead and says so in the engine badge.

Does minifying CSS break anything?

It should not. Both engines keep strings, url() values, calc() spacing and custom property values intact, and the built-in engine never changes selectors or rule order. Test the page once after minifying, especially when restructuring is enabled.

Why are /*! */ comments kept?

Comments that start with /*! are the convention for license and copyright notices that must stay in distributed files. Untick “Keep /*! important */ comments” to remove them too.

How much smaller will my CSS be?

Hand-written stylesheets typically shrink by 15–30%. Files with many comments or long indentation shrink more. Serve the result with gzip or Brotli for the best transfer size.

Is my CSS sent to a server?

No. Minification runs entirely in your browser. Only the csso library itself is downloaded from the CDN; your code is never uploaded.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

CSS FormatterBeautify CSS with indent controls and optional property sorting.HTML FormatterBeautify and indent HTML code with a live preview.JavaScript BeautifierFormat and beautify messy or minified JavaScript, or minify it.SQL Formatter & BeautifierFormat, beautify or minify SQL queries for MySQL, PostgreSQL and more.Core Web Vitals CheckerCheck real-user LCP, INP and CLS for any URL or site and see if it passes Core Web Vitals.CSS Border Radius GeneratorRound each corner, draw elliptical 8-value radii or random blob shapes and copy the CSS.CSS Box Shadow GeneratorDesign layered CSS box shadows with a live preview, presets and one-click Copy CSS.CSS Button GeneratorDesign CSS buttons with gradients, borders, shadows and hover and active states, then copy the code.JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.XML FormatterBeautify, validate and minify XML with a collapsible tree view.ZIP File CreatorCompress files and folders into a ZIP.YAML Validator & FormatterValidate, format and minify YAML, and convert YAML to JSON or back.HTML MinifierMinify HTML: strip comments and whitespace safely and see how many bytes you save.JavaScript MinifierMinify JavaScript with Terser: compress, mangle and see how many bytes you save.Code Diff CheckerCompare two code files side by side or unified, with syntax colors and changes highlighted.IPv6 Expander & CompressorExpand IPv6 addresses to full form or compress them per RFC 5952, one or many at once.GraphQL FormatterPretty-print and indent GraphQL queries, mutations and schemas, or minify them, instantly.CSS ValidatorValidate CSS: syntax errors, unknown properties and invalid values by line, plus auto-fix.Gzip Compress / DecompressGzip or deflate text and files, get Base64 output, and decompress Base64 or .gz files.IBAN ValidatorCheck an IBAN's mod-97 checksum, country and length, and see its bank code and account parts.JavaScript Syntax CheckerCheck JavaScript for syntax errors with line and column, for any ES version, script or module.JSON Schema ValidatorValidate JSON against a JSON Schema (draft-07, 2019-09, 2020-12) with clickable error paths.Markdown FormatterBeautify Markdown with Prettier: list markers, prose wrap, aligned tables and live preview.PHP FormatterBeautify PHP code with Prettier PHP: PSR-12 style, indent and brace options, syntax errors.TypeScript FormatterFormat TypeScript and TSX code with Prettier: width, tabs, semicolons and quotes options.XML MinifierMinify and validate XML: strip whitespace and comments, keep CDATA, see the size savings.C# FormatterBeautify C# code online: Allman or K&R braces, indent size and line width, clang-format option.HTML ValidatorCheck HTML for errors and warnings with line numbers, locally or with the W3C Nu checker.Java FormatterBeautify Java code online: indent size, brace style and line width, with clang-format option.Phone Number FormatterFormat and validate lists of phone numbers to E.164, international or national style.Python FormatterFormat Python code in Black/Ruff style: line length, quote style, indent, copy or download.Responsive Design CheckerPreview any website at phone, tablet, laptop and desktop sizes side by side, with rotate and zoom.Browser Compatibility CheckerSearch CSS, JavaScript and HTML features and see which browser versions support them.Heading Structure CheckerPaste HTML to see its H1-H6 outline and catch missing H1s, multiple H1s and skipped levels.Website Hosting CheckerFind out who hosts a website: hosting provider, IP addresses, ASN, network owner and location.Routing Number ValidatorCheck a US ABA routing number's checksum and format and see its Federal Reserve district.Spam Word CheckerScan an email subject and body for spam trigger words, excess caps, exclamation marks and risky links.Check Digit CalculatorCalculate or validate check digits for UPC, EAN, GTIN, SSCC, ISBN, ISSN and mod 11 codes.Luhn Algorithm CheckerValidate numbers with the Luhn mod 10 check or calculate the missing check digit, step by step.XSD ValidatorValidate XML against an XSD schema in your browser and see each error with its line number.Strftime Format BuilderBuild Python and C strftime format strings by clicking tokens, with a live preview and reference.
See all 41 Code Formatters & Validators →