CSS Minifier and Beautifier
Compress a stylesheet or expand a minified one, with strings, comments and calc() handled properly.
Processed on your device — no upload
Strings and url() values are copied untouched, and spaces inside calc() are kept — removing them there produces a rule the browser silently discards, which is the classic way a minified stylesheet loses a layout.
How to use it
- Paste your CSS.
- Choose minify or beautify.
- Copy or download the result.
How it works
Minifying removes what the browser does not read: comments, indentation, the newline after every declaration, the final semicolon in each block. A typical hand-written stylesheet loses a quarter to a third of its bytes, and none of its meaning.
The trap is that whitespace in CSS is sometimes load-bearing. In calc(100% - 2rem) the spaces around the minus sign are required by the specification. Remove them and you get calc(100%-2rem), which is invalid — and CSS fails silently, so the browser drops that one declaration and your layout changes with no error anywhere.
This minifier tracks parenthesis depth. Outside parentheses, + and ~ are selector combinators and the spaces around them go. Inside, they are arithmetic and the spaces stay.
Strings and comments are handled by walking the text, not by regular expression. A URL containing /*, or a content property holding a quote, defeats the regex approach — and the failure is a stylesheet truncated from that point on.
Comments beginning /*! are kept. That is the convention for licence headers, and stripping them from a library is a licence violation rather than an optimisation.
A worked example
Press "Load a sample" and minify it. The sample is written to contain the traps: a calc() with spaces, a comment, a grouped selector, ana:hover pseudo-class and a media query. Check the output — calc(100% - 2rem) survives intact, the comment is gone, and @media (min-width:560px) keeps its structure.
Beautifying is the more common need in practice. You are looking at a minified stylesheet from a site, or a build output you need to debug, and it is one line 40,000 characters long. Expanding it makes it readable — the round trip through minify and back is lossless except for the comments, which were already gone.
An honest note about where this fits. If you have a build step, use it — a real toolchain also merges duplicate rules, shortens colours, and removes declarations that are overridden later. This tool is for the cases where you do not have one: a snippet for an email template, a stylesheet you were handed, a theme file in a CMS text box, an inline block in a landing page.
Compression matters more than minification. Gzip and Brotli already collapse repeated whitespace very effectively, so a minified file often gzips to only slightly less than the original. Minify anyway — it is free — but if the file is served uncompressed, fixing that is worth ten times more.
For markup rather than styles, the HTML minifier handles the whitespace rules that apply there.
Questions
Can it prettify minified CSS as well?
Yes, both ways. Beautify will format a stylesheet that arrived as one long line, which is usually why people come to this page.
Will minifying break my CSS?
Not here. Spaces inside calc() are preserved, strings and url() values are copied verbatim, and the parser walks the text rather than matching patterns.
How much smaller will it get?
Typically 20–35% for hand-written CSS, mostly indentation and comments. Already-compact code saves less.
Is the round trip lossless?
Everything but comments. Minifying then beautifying gives you back working, readable CSS with the same rules in the same order.
Why are some comments kept?
Comments starting /*! are licence headers by convention. Removing them from a third-party library breaks its licence terms.
Does it merge duplicate rules?
No. It only removes what the browser ignores. Restructuring your CSS is a job for a full toolchain, where you can review what changed.
Should I minify if my server uses gzip?
Yes, but expect a smaller win than the raw byte count suggests — compression already handles repeated whitespace well. Serving the file compressed matters far more.
Can it handle CSS custom properties and nesting?
Custom properties yes. Native nesting works as well, since it follows the same brace structure.
Is my stylesheet uploaded?
No. It is processed in this page, which also means very large files are limited only by your own machine.
Related Web tools
Color Converter
HEX, RGB, HSL, HSV, CMYK
open$termiva contrast --wcagColor Contrast Checker
WCAG AA and AAA, with a fix
open$termiva palette --triadicColor Palette Generator
Harmonies and a full tint scale
open$termiva gradient --linearCSS Gradient Generator
Linear, radial and conic
open