CSS Minifier

Minify CSS — strip comments and needless whitespace to shrink a stylesheet — right in your browser. A fast whitespace minifier, not a structural optimiser.

Developer ToolsTrending Free No upload Instant

Loading CSS Minifier…

Your browser is preparing the tool. It runs 100% locally.

Quick Answer

Paste CSS and the tool removes comments and the whitespace around braces, colons, semicolons and commas, collapsing the stylesheet toward a single compact line. It is a fast whitespace minifier — it does not do structural optimisation like shortening colours or merging rules, the way cssnano does. It is great for a quick size cut and shows the saving. Everything runs in your browser; nothing is uploaded.

What the CSS Minifier Does

This tool takes a readable stylesheet and compresses it by removing the parts that browsers ignore: comments, the spaces and line breaks around the structural punctuation, and the redundant final semicolon in each rule. The result is smaller CSS that behaves identically.

It is the quick way to shave bytes off a stylesheet for production or for pasting inline, when you do not have a build step running and just want a fast size cut.

How It Works

The tool runs a few regular expressions: it deletes comment blocks, removes the whitespace on both sides of braces, colons, semicolons, commas and child-combinator marks, drops the last semicolon before a closing brace, and collapses any remaining runs of whitespace to a single space.

This is pattern-based, not a parse. It keys off the structural punctuation rather than understanding selectors, properties or values. That makes it fast and dependency-free, and it shrinks ordinary CSS well, but it only removes whitespace — it does not rewrite or optimise the CSS itself.

Processing pipeline

  1. Remove comments. Delete comment blocks, which browsers ignore anyway.
  2. Trim around punctuation. Remove whitespace on both sides of braces, colons, semicolons, commas and child-combinator marks.
  3. Drop the last semicolon. Remove the redundant semicolon just before each closing brace.
  4. Collapse whitespace. Reduce any remaining whitespace runs to a single space and trim the result.

What minifying removes

• delete comment blocks • remove whitespace around { } : ; , and the child-combinator mark • drop the last semicolon before a closing brace • collapse remaining whitespace to single spaces
Worked example
Before: body { margin: 0; padding: 10px; } After: body{margin:0;padding:10px}

It shrinks by whitespace only. It does not shorten colours, merge duplicate rules, drop overridden declarations or reorder anything — the CSS is the same, just smaller on disk.

Privacy

Your CSS never leaves your device. It is minified in your browser with no network request, so nothing is uploaded.

Because the work is local, you can safely compress proprietary or unreleased styles without them being stored or sent anywhere.

Nothing persists between sessions — close the tab and the input and output are gone.

Standards & references

  • CSS syntax — Whitespace between most tokens, comments, and a final semicolon before a closing brace are all optional. The tool removes exactly those, keying off the structural punctuation.
  • Whitespace vs structural minification — Simple minifiers strip whitespace and comments. Tools like cssnano go further on an AST — compressing colours, merging identical keyframes, and discarding overridden rules. This tool does the whitespace part only.
  • Meaningful whitespace — Some whitespace matters — inside a string value, a data URI, or a calc() expression. Because the tool keys off punctuation, content like that can be affected, so check the output for such cases.

Accuracy & Limitations

It shrinks ordinary CSS reliably, but it is a whitespace minifier, not an optimiser. It only removes spacing and comments — it does not shorten hex colours, collapse margins, merge duplicate selectors or drop overridden declarations the way a structural tool does. The size cut is smaller as a result.

It keys off punctuation, so content that contains that punctuation can be affected. A semicolon or comma inside a string value or a data URI, or the meaningful spaces inside a calc() expression, may be collapsed or trimmed in ways that change the result. Check the output if your CSS has those.

It removes the final semicolon before each closing brace, which is always safe, and it strips comments — including any licence comment you may have wanted to keep. Add those back if you need them.

It is a one-way size cut, not a reversible format. To make the CSS readable again you would run it through a formatter, which re-adds whitespace but cannot restore the comments that were removed.

Real-World Use Cases

Shaving bytes for production

Compress a stylesheet when you have no build step running.

Inlining CSS

Minify a small stylesheet to drop into a style block.

Quick size check

See how much whitespace your CSS is carrying.

Tidying before transfer

Compress CSS to send or embed compactly.

When to use it — and when not to

Good for

  • A fast whitespace-and-comment size cut
  • Minifying a small stylesheet inline
  • A quick, no-build compression
  • Seeing the whitespace saving

Not the best choice for

  • Structural optimisation (colours, rule merging)
  • CSS with data URIs or calc() you need intact
  • Preserving licence comments
  • Production builds that need maximum compression

For maximum, safe compression that also optimises colours, merges rules and drops dead declarations, use cssnano or a bundler's CSS minifier in your build. To make minified CSS readable again, run it through a CSS formatter.

Frequently Asked Questions

How does it shrink my CSS?
By removing comments and the whitespace around structural punctuation, dropping the redundant final semicolon in each rule, and collapsing remaining whitespace. The CSS behaves the same; it is just smaller.
Does it optimise the CSS, like shortening colours?
No. It is a whitespace minifier only. It does not shorten hex colours, merge duplicate rules, collapse shorthand or drop overridden declarations. For those, use a structural minifier like cssnano.
Will it break a data URI or calc() expression?
It can. Because it keys off punctuation and whitespace, a semicolon or comma inside a data URI, or the meaningful spaces in a calc() expression, may be altered. Check the output if your CSS contains those.
Does it remove my comments?
Yes, all of them — including any licence or attribution comment. If you need to keep a comment, add it back after minifying, or use a tool with a comment-preserving option.
Is it a real CSS parser?
No. It uses regular expressions keyed off braces, colons, semicolons and commas. It does not understand the CSS grammar, which is why it is fast but limited to whitespace removal.
How much smaller will my file be?
It depends how much whitespace and how many comments the CSS had. Heavily commented, indented stylesheets shrink more; already-tight CSS shrinks little. The saving is whitespace only.
Can I reverse it?
You can re-indent minified CSS with a formatter, which restores readability but not the comments that were removed. The rules themselves are unchanged.
Is removing the last semicolon safe?
Yes. The semicolon before a closing brace is optional in CSS, so removing it never changes behaviour and saves a byte per rule.
Is my CSS uploaded anywhere?
No. It is minified entirely in your browser. Nothing is sent to a server, so private styles stay on your device.
Should I use this or a build-tool minifier?
For a quick, no-build size cut this is handy. For production, a structural minifier like cssnano in your build compresses more and handles edge cases like data URIs safely.
Does it minify across media queries and nested rules?
It removes whitespace throughout, including inside at-rule blocks. It does not understand their structure, though, so it will not merge or optimise them — only their whitespace is reduced.
Will it change which styles apply?
It should not, for ordinary CSS — removing whitespace and comments does not change the rules. The exceptions are the edge cases noted above (data URIs, calc()), so verify those if present.

References

Shrinks by removing comments and the whitespace around braces, colons and semicolons; honest that it is a whitespace-only minifier, not an optimiser that shortens colours or merges rules.

PopularHot

JSON Formatter

JSON Formatter for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

JSON Validator

JSON Validator for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

Base64 Encoder

Base64 Encoder for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

Hash Generator

Fast, free Hash Generator that runs entirely client-side in your browser.

DeveloperOpen Tool
Popular

UUID Generator

Fast, free UUID Generator that runs entirely client-side in your browser.

DeveloperOpen Tool
Trending

Regex Tester

Regex Tester online: paste, process and copy without your data hitting a server.

DeveloperOpen Tool

Ready to try the CSS Minifier?

It is free, private and runs entirely in your browser — no sign-up, no uploads, no limits.