CSS Minifier

Shrink a stylesheet by stripping comments and needless whitespace in your browser. It removes spacing only and leaves the rules themselves alone.

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, so 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. It all happens in this tab, and 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.

Use it to shave bytes off a stylesheet for production or for pasting inline when you have no build step running.

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 stays the same and takes less space 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 carries over between visits. 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 those, keying off the structural punctuation.
  • Whitespace vs structural minification: Simple minifiers strip whitespace and comments. Tools like cssnano work on an AST and go further: they compress colours, merge identical keyframes and discard overridden rules. This tool does the whitespace part only.
  • Meaningful whitespace: Some whitespace matters, such as 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 and limits

It shrinks ordinary CSS reliably, but it removes only 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.

Where people use it

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 it fits, and when it doesn't

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 and takes fewer bytes.
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. Your browser does the minifying and sends nothing 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. It only reduces their whitespace.
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; it removes whitespace only and does not shorten colours or merge rules.

PopularHot

JSON Formatter

Pretty-print messy or minified JSON with 2-space indents.

DeveloperOpen
Popular

JSON Validator

Paste JSON and find out whether it parses.

DeveloperOpen
Popular

Base64 Encoder

Standard Base64 for any text, emoji included.

DeveloperOpen
Popular

Hash Generator

MD5, SHA-1 and the SHA-2 hashes of any text, as you type.

DeveloperOpen
Popular

UUID Generator

Up to 500 random version 4 UUIDs at once.

DeveloperOpen
Trending

Regex Tester

Live match highlighting and a count, using JavaScript regex.

DeveloperOpen

Back to the CSS Minifier

Paste, run and copy. The code stays in your browser and you don't need an account.