# Minify CSS Code

> Minify CSS code by removing whitespace, comments, and redundant rules to reduce file size. Paste production code, API keys, tokens.

Live tool: https://lofttools.com/tools/dev-tools/css-minifier

Category: Dev Tools

## How it works

1. **Paste CSS** — Paste your CSS code into the input area
2. **Minify** — The CSS is minified automatically with size reduction stats
3. **Copy result** — Copy the minified CSS or download as a file

## FAQ

### Are CSS custom properties (variables) preserved?

Yes. `--variable-name` declarations and `var(--x)` references pass through untouched. Minification only strips comments, collapses whitespace, merges shorthand properties, and removes redundant units on zero values.

### Does it rewrite selectors or merge duplicate rules?

No. Selector rewriting and rule merging can change specificity or the order of property application — both have silent correctness risks. This minifier is intentionally conservative; the parsed output is semantically identical to the input.


### Can I round-trip between minify and beautify?

Yes. Toggle to "beautify" mode to pretty-print minified CSS. Round-tripping minify → beautify → minify produces identical bytes. Original author comments (`/* ... */`) are stripped on minify and cannot be recovered by beautify.

## Privacy

This tool runs entirely in the browser. Files are not uploaded to a server. They never leave the user's device.

## More

- All tools: https://lofttools.com/tools
- Category: https://lofttools.com/tools/dev-tools
- LLM index: https://lofttools.com/llms.txt
