CraftTools

CSS Minifier & Beautifier

Guide: px vs rem vs em: Which CSS Unit Should You Use?

234 → 172 bytes (26% smaller)

Nothing you enter or choose here leaves your device. This tool runs in your browser.

A real before and after

/* header */
body {
  margin: 0px;
  padding: 0.5em 1em;
  color: #ffffff;
}

.btn:hover {
  background: rgba(0, 0, 0, 0.5);
}
body{margin:0px;padding:.5em 1em;color:#ffffff}.btn:hover{background:rgba(0,0,0,.5)}

That went from 127 characters to 84, a saving of about a third. The comment is gone, the white space is gone, the last semicolon in each rule is gone and 0.5 became .5. Real stylesheets full of comments and indentation often shrink by 20 to 40 percent.

What it changes and what it leaves alone

Removed or shortenedKept as written
CommentsComments starting with /*!, which usually hold licenses
Line breaks and indentationValues, selectors and colors, so #ffffff stays
The last semicolon in a ruleText in strings and inside url()
Leading zeros, as in 0.5emSpaces that matter, such as inside calc() and between selectors

It's deliberately conservative. Tools that rewrite values, merge rules and remove unused CSS can save more, but they can also break a layout. Here, what you paste is the same CSS in fewer bytes.

Does it really matter?

A bit. CSS blocks the page from displaying until it's loaded, so a smaller file helps pages appear sooner, particularly on slow phone connections. But the server probably compresses files in transit already, and that shrinks CSS far more than minifying does. Minifying plus compression is better than either alone. If you have to choose, switch on compression first.

Beautify for reading

The other mode does the reverse. Paste a minified stylesheet from a site you're inspecting, or one that comes from a plugin, and choose an indent. It breaks it back into one declaration per line so you can read it. The names of the rules are the same, and the comments aren't brought back.

A safe workflow

  1. Keep your readable source files and don't edit the minified copy.
  2. Minify as the last step before publishing, and save it under a separate name like style.min.css.
  3. Load the page and check the main layouts on a phone and a desktop.
  4. If something looks off, compare against the unminified file. A missing space inside calc() is the usual culprit.

What it doesn't do

It doesn't join several files into one, remove rules nothing uses or add browser prefixes. For those, use a build tool such as PostCSS. Your CSS stays in your browser. If you're sizing text, the px to rem converter helps, and the CSS generator builds gradients and shadows. The HTML formatter tidies the markup that goes with it.

Written by Akinrinmade Michael · Updated October 24, 2026

How to use

  1. 1Choose Minify or Beautify.
  2. 2Paste your CSS into the input box.
  3. 3Check the result and the size saved.
  4. 4Click Copy CSS, or Download .css.

Frequently asked questions

What does the minifier remove?

Comments, line breaks, extra spaces and the last semicolon in each rule, and it turns 0.5em into .5em. Comments that start with /*! are kept because they usually hold licences.

Is it safe for my stylesheet?

It doesn't rewrite values, selectors or colors, and it leaves strings and url() contents untouched. Spaces that matter, such as inside calc() and between selectors, are kept.

Does it combine files or remove unused CSS?

No. It only compresses the text you paste. To remove unused rules or merge files, use a build tool such as PostCSS.

Is my CSS uploaded?

No. It is processed in your browser and nothing is sent anywhere.

Read the guides

Learn how this works and how to get the most from it.

Web & SEO

px vs rem vs em: Which CSS Unit Should You Use?

The difference between px, rem and em in CSS, how to convert between them, and when each one is the right choice.

3 min read

Web & SEO

HTML Entities, Formatting and Minifying Explained

When to escape characters in HTML, how formatting and minifying differ, and how much minifying HTML, CSS and JavaScript really saves.

3 min read

JavaScript Minifier

Strip comments and spaces from JavaScript. Safe and private.

HTML / XML Formatter & Minifier

Beautify or minify HTML and XML.

CSS Gradient & Box Shadow Generator

Design gradients and box shadows visually and copy the CSS.

PX to REM Converter

Convert px to rem, em, pt and percent for any base font size.