# CSS Minifier & Beautifier

> Minify CSS to make stylesheets smaller, or beautify minified CSS to read it. Keeps strings, url() and calc() safe, indents @media and can keep licence comments.

Canonical: https://cromagnon.app/tools/css-minifier
Last updated: 2026-10-25

- Category: Developer
- Formats: CSS
- Use it: https://cromagnon.app/tools/css-minifier (free, runs in the browser)

## What it does

Minify CSS to make stylesheets smaller and faster to load, or beautify minified CSS so you can read and edit it. Text in quotes, url(…) values and calc() expressions are never broken, nested @media and @supports rules are indented, and /*! licence comments can be kept.

## How to use it

1. Paste your CSS into the Input box (or press Sample).
2. Choose Minify, or Beautify with 2, 4 or 8 spaces or a tab. When minifying you can keep /*! licence */ comments.
3. Read the status line: the size before and after, and how much was saved.
4. Copy or download the result.

Tip: Minified CSS is hard to debug. Keep the readable file in your project and minify a copy for the live site, or let your build tool do it.

## What minifying removes (and what it never touches)

- **Removed**: Comments, line breaks, indentation, spaces around { } : ; , and >, and the last ; in each rule.
- **Kept exactly**: Text in quotes (content: "a ; b"), url(…) values including data: URLs with ; inside, and !important.
- **Spaces that matter**: calc(100% - 2rem) keeps the spaces around - and +, which calc() needs; .menu :hover keeps the space that makes it different from .menu:hover.

## Beautifying minified CSS

Beautify puts each selector on its own line with an opening brace, each declaration on its own line with a space after the colon, and a blank line between rules. Rules inside @media, @supports and @layer are indented one more level, so you can see at a glance which styles apply on small screens.

Selectors are spaced for reading (.card > .title) and media queries are tidied to (max-width: 600px).

## How much does minifying save?

Usually 15–30% for hand-written CSS, more for files with long comments. Your server's gzip or Brotli compression then shrinks the file much further, often by 70–80%, so minifying and compressing together give the smallest download.

Smaller CSS matters because the browser can't show the page until the stylesheet has loaded; it's one of the things Core Web Vitals reports point to.

## Licence comments

Libraries such as Bootstrap and Font Awesome start with a /*! … */ comment holding their licence, which many licences ask you to keep. Tick keep /*! licence */ comments and those stay while every other comment goes.

## Reading a CSS rule

- **Selector**: .card > .title picks which elements the rule styles: here, a .title directly inside a .card.
- **Declaration block**: Everything between { and }: the styles to apply.
- **Property and value**: color: #071a2f; one property, a colon, its value and a semicolon.
- **At-rules**: @media, @supports, @font-face and @keyframes wrap rules that apply only in some cases or define something reusable.
- **Comments**: /* … */ notes for people, removed when minifying.

## Minify vs compress vs purge

- **Minify**: Removes characters the browser ignores. Safe, quick, and what this tool does.
- **Compress (gzip / Brotli)**: Done by your web server when sending the file; it shrinks text much further and is undone by the browser.
- **Purge unused CSS**: Removes rules no page uses, which needs your site's HTML; tools such as PurgeCSS do this in a build step.

## Tips

- **Read a site's CSS**: Open a stylesheet from the browser's developer tools, copy it and beautify it to learn how a design is built.
- **Inline critical CSS**: Minify the small set of rules needed for the top of the page and put them in a <style> tag.
- **Check before you ship**: Beautify your minified output once; if it reads back correctly, nothing was lost.
- **Combine first, then minify**: Joining several stylesheets into one file saves requests; minify the combined file.
- **Watch the order**: Minifying never reorders rules, so the cascade works exactly as before.
- **Keep secrets local**: Your stylesheets are processed in your browser and never uploaded.

## Questions

### How much smaller does CSS get?

Usually 15–30%, more when the file has many comments. Your server's gzip or Brotli compression saves even more on top.

### Is minified CSS safe to use?

Yes. Only characters browsers ignore are removed; text in quotes, url() values and calc() spacing are kept exactly.

### Can I un-minify CSS?

Yes. Choose Beautify and minified CSS is laid out with one declaration per line again. Removed comments can't come back.

### Does it support @media and nested rules?

Yes. Rules inside @media, @supports and @layer are kept and indented when beautifying.

### Will it change my colours or units?

No. Values are kept as written; only whitespace and comments are removed.

### Does it work with Sass or Less?

Plain CSS works best. Compile Sass or Less to CSS first, then minify the result.

### What does /*! mean in a comment?

It marks a comment to keep when minifying, usually a licence. Tick keep /*! licence */ comments to keep them.

### Will minifying break my CSS?

No. The tool only removes comments, spaces and the last semicolon in each block. Text in quotes, url() values and the spaces calc() needs around + and - are kept, so the browser reads the minified file the same way.

### How much smaller will my CSS get?

Usually 15 to 30 percent, depending on how many comments and how much indentation the file has. The tool shows the exact sizes and the percentage under the output.

### Can I turn minified CSS back into readable CSS?

Yes. Switch to Beautify and each rule and declaration goes on its own line with the indent you choose. Comments removed during minifying can't come back, so keep your original file.

### Is my code uploaded?

No. The tool runs in your browser; what you paste never leaves your device and nothing is stored on a server.

## Related

- [HTML Formatter](https://cromagnon.app/tools/html-formatter)
- [JavaScript Minifier](https://cromagnon.app/tools/js-minifier)
- [Color Converter](https://cromagnon.app/tools/color-converter)
- [Colour Palette from Image](https://cromagnon.app/tools/color-palette)
- [All tools](https://cromagnon.app/tools)
