CSS Minifier
Strip comments and whitespace from CSS to shrink file size.
This tool runs entirely in your browser. Your data is never uploaded, never stored, and never leaves your device.
Stripping comments, collapsing whitespace and dropping empty rules shrinks a stylesheet here, and the same tool runs the process backwards to re-indent a minified file into readable blocks.
How to use it
- 1Leave Minify selected and paste your stylesheet into the CSS Input box.
- 2Read the result, and the line beneath it giving before and after byte counts.
- 3Switch to Beautify to expand a minified file into one declaration per line.
Example
- Input
- /* card */ .card { color: #333; margin: 0 auto; } .empty {}
- Output
- .card{color:#333;margin:0 auto}
63 B → 31 B, saved 51%. The empty .empty {} rule is deleted outright and the last semicolon before } goes with it.
What happens to your data
Before anything is collapsed the stylesheet is cut into quoted and unquoted segments, and the whitespace rules are applied only to the unquoted ones — so a font name or a data: URI inside quotes is copied through character for character rather than rewritten. The saving figure is measured in the page with TextEncoder on both strings; it is a local byte count, not a score fetched from anywhere.
Last updated August 2026
You have a stylesheet that has grown, and something wants it smaller — a page weight budget, an inline style block in an HTML email, a theme field that takes CSS and counts characters. Or the opposite: someone has handed you one unbroken line of minified CSS and asked what a rule in the middle of it does.
Those are two different jobs and only one of them saves anything. Minifying produces output — the copy a browser downloads. Beautifying produces something to read, and the file it makes is larger than what went in. Neither replaces a build step: if your project already runs a bundler, minification belongs there, where it happens on every deploy and nobody has to remember. A paste box makes sense for a site with no build at all, a snippet going into a template, or a file you have been given and need to understand.
Settle what you expect the saving to be before you press anything. Whitespace and comments are the easy weight, and they are also precisely what gzip and brotli were designed to remove, so the figure you see under the output overstates what actually crosses the wire. Minifying still helps, and it helps most where compression is not in play.
The common mistake is running it over the file you edit. Minified CSS is output rather than source — keep the readable copy, and treat the compressed one as something you can throw away and regenerate at any time.
How it works
Toolvore works over the text rather than by parsing CSS into a tree. Comments go first, with the scanner stepping over quoted strings as it goes, so a /* sitting inside a font name or a data URI is not mistaken for the start of one. What is left is cut into quoted and unquoted segments, and the whitespace rules touch only the unquoted parts: runs of whitespace collapse to one space, space around braces, colons, semicolons, commas and the child combinator disappears, the space before !important goes, and a semicolon sitting immediately before a closing brace is dropped. Empty rules are then deleted repeatedly, so a block left hollow by comment removal takes its parent with it when nothing else remains inside. Beautify runs that same minifier first and rebuilds from the result, which is why it can never give comments back. The honest weakness is that nothing is validated — unbalanced braces pass straight through — and values are left alone: colours are not shortened, units are not trimmed, duplicate declarations are not merged, and unused rules are not found.
Common use cases
- Shrinking a stylesheet on a site that has no build step
- Reading a minified file someone has handed you with no source
- Trimming a CSS snippet to fit a theme field that counts characters
- Preparing an inline style block for an HTML email
- Cleaning up a stylesheet inherited from an old template before editing it
- Checking how much of a file is comments and indentation
- Re-indenting CSS copied out of a browser inspector
Frequently asked questions
What does minifying CSS actually remove?+
Four things, and nothing else. Comments in the /* */ form go completely. Runs of whitespace collapse to a single space, and the space either side of a brace, colon, semicolon, comma or child combinator goes entirely. The final semicolon before a closing brace is redundant in CSS and is dropped. And rules with an empty body are deleted. What is not touched is the substance: every selector, property and value arrives on the other side spelled exactly as you wrote it. A six-digit hex colour does not become a three-digit one, a zero with a unit keeps its unit, and two rules setting the same property are both kept.
How much smaller will my stylesheet get?+
Entirely down to how the file was written. A stylesheet with a comment above every section and generous indentation loses a large share of its bytes to formatting alone; one exported by a tool that already wrote it densely may barely move. The counter under the output measures both versions in UTF-8 bytes on your own machine, so it is a real measurement of the two strings rather than an estimate — but it is a measurement of the file, not of what a visitor downloads, which depends on compression as well. Paste your file in once and you will know where it sits.
Does minified CSS behave the same in the browser?+
It should, because whitespace in CSS is meaningful in only a few places and those are left alone. Text inside quotation marks is copied through character for character, so a font family with spaces in its name, a content string, and the row strings in grid-template-areas all survive intact. The descendant combinator is itself a space and it is kept — only the spaces around braces, colons, semicolons, commas and the child combinator are removed. The gap that bites is unquoted content: a data URI or an inline SVG pasted into a property without quotes can have spaces taken out of the middle of it. Quote those.
Can minified CSS be turned back into the original file?+
Not the original — only something readable. Beautifying restores structure: one declaration per line, two-space indentation for nested blocks, a space after the colon in each declaration and after the commas in a selector list, and a blank line between top-level rules. What it cannot restore is anything the minifier discarded, and comments are the big loss. The path runs through the minifier first, so beautifying gives you back layout and never the author's notes. Original line breaks, blank lines used for visual grouping, and any indentation style other than two spaces are gone the same way.
Is my stylesheet uploaded anywhere?+
No. The whole thing runs inside the page you are looking at. There is no upload control and no file picker — the only way in is pasting into the text box — and the result is recomputed in the browser from that text as you type. The byte figures are worked out on your machine too, counted with the browser's own UTF-8 encoder rather than fetched from anywhere. Nothing is kept between visits either: the input lives only in the page's memory, so reloading the tab leaves you with an empty box. That matters when the stylesheet belongs to a site nobody has seen yet.
Is minifying worth it if the server already uses gzip or brotli?+
Less than the raw byte figure suggests, but usually still worth it. Compression algorithms handle repeated whitespace extremely well, so most of what minifying removes is exactly what gzip would have squeezed anyway — the gap between compressed minified and compressed formatted CSS is far narrower than the gap between the two uncompressed files. Where minifying earns its place is wherever compression is not applied: CSS pasted inline into an email, a style block in a page served without it, a field with a character limit. Minify by default in a build, and do not expect the headline saving on the wire.
Why did part of my CSS vanish after minifying?+
Almost always empty rules. A rule whose body held only a comment has nothing left once comments are stripped, so it is deleted — and the deletion runs repeatedly, meaning a wrapper such as a media query block that contained only that rule is removed on the next pass. Placeholder selectors left in for later, and an at-rule kept open for a feature you have not written yet, both disappear this way. The other loss people notice is a licence banner. Comments opening with an exclamation mark are conventionally preserved by build tools; here they are not, so keep that header separately if the licence requires it.
Can I minify Sass or Less this way?+
Only after it has been compiled. Sass and Less are separate languages that produce CSS, and what works here is the CSS. Two things go wrong if you paste the source in. Single-line comments starting with two slashes are not CSS and are not recognised, so rather than being removed they lose their line break and swallow whatever followed onto the same line. Variables, mixins and nested selectors written with the parent reference pass through untouched, which leaves you holding a smaller file that no browser can use. Compile first and minify the output — the order a build pipeline uses anyway.
Used in these workflows
Related tools
Chmod Calculator
Convert between symbolic and octal Unix file permissions.
JavaScript Keycode Finder
Press any key to see its event.key, code, and keyCode.
JSON Formatter & Validator
Format, validate, and minify JSON documents.
Cron Expression Parser & Builder
Build cron expressions and see their next run times explained.