DataToolsLab
Code Formatter Tools

CSS Minifier

Remove whitespace, comments and redundant semicolons from CSS for production builds.

Loading tool…

What is CSS Minifier?

A CSS minifier for the last step before deploy. It removes everything the grammar does not need and leaves alone everything it does — including the space in `1px solid red` and the one after `and` in a media query.

How it works

Tokens are re-emitted without whitespace, and a space is inserted only between two characters that would otherwise join into a different token. Comments are dropped unless they start with /*!, the semicolon before a closing brace is removed, and rules that would end up empty disappear entirely.

  1. Paste the source. Drop in code, a stylesheet, a query or a selector list. Everything is read locally — the page never uploads what you paste.
  2. Choose the options. Indent width, quote style, keyword case or target browsers. The result updates as you change them, so you can see the effect immediately.
  3. Copy or download. Copy the result to the clipboard or download it as a file. Reset clears the form and returns every option to its default.

Examples

A minified bundle → readable code

Beautifying a 40 KB one-line stylesheet or script turns it into something reviewable, without altering a single token of the program itself.

A query moved between databases

MySQL's backticks, AUTO_INCREMENT and LIMIT 10, 20 become PostgreSQL's double quotes, identity columns and OFFSET — with a list of what still needs a human.

A stylesheet that only breaks in Safari

backdrop-filter, user-select and position: sticky need -webkit- prefixes for older Safari, which the CSS Autoprefixer adds for exactly the targets you tick.

Common mistakes

Expecting a formatter to fix invalid code

Formatting is whitespace and quoting. A missing brace, an unclosed tag or an unquoted variable survives the round trip and is reported instead — check the findings list.

Minifying without running the tests afterwards

Even a safe, non-mangling minifier can expose an existing automatic-semicolon-insertion bug. The JavaScript Minifier keeps the newlines that matter, but re-run your tests before shipping.

Treating a rewritten query as verified

The SQL Dialect Converter translates the syntax it can prove; data types, casts and function differences are listed for review, not guessed. Run the converted query against a real database.

Renaming or reformatting generated files

Regenerating a formatter's output is a no-op only if the formatter is the same one that produced it. Keep generated code out of the round trip and format the source it came from.

Frequently asked questions

Why are some spaces kept?

Because they are part of the grammar. Minifying `border: 1px solid red` to `border:1pxsolidred` would produce a different value, and `@media screen and (color)` needs the space before the parenthesis.

Is 0px → 0 always safe?

For lengths, yes — 0px, 0em, 0% and friends are all zero lengths. The one place it matters is an animation or transition timing function where a unitless 0 is required anyway, so shortening it is still correct. The option can be turned off if you prefer the explicit form.

Should I minify before or after autoprefixing?

After. Run the CSS Autoprefixer (or your build pipeline) first, then minify the final stylesheet — this tool adds nothing, it only removes.

Online