Internative Logo

CSS Minifier and Beautifier: Shrink or Format CSS in Your Browser

CSS Minifier and Beautifier: Shrink or Format CSS in Your Browser

Minifying CSS means removing everything the browser does not need to read it: comments, line breaks and extra spaces. The file gets smaller and downloads faster, and the styles behave the same. The tool below minifies a stylesheet you paste, or goes the other way and formats a compressed one so a person can read it. It runs in your browser, so your code is not sent anywhere.

CSS minifier and beautifier

Remove comments and spaces to shrink a stylesheet, or lay it out with indentation to read it.

Output

What you enter never leaves your browser. Nothing is sent or stored.

How to use the tool

  1. Paste your CSS into the input field.
  2. Press Minify to get the compact version, or Beautify to get an indented, readable one.
  3. Copy the result.

Minify removes comments, collapses runs of whitespace, strips the spaces around {, }, :, ;, , and >, and drops the last semicolon in each block. Beautify reformats the code with two-space indentation, one declaration per line.

What it does not do

This is a deliberately simple minifier. It does not merge rules, shorten values such as #ffffff or 0px, remove unused selectors or reorder anything. A build tool such as a bundler or a dedicated CSS optimizer can save more, and is the right choice for a real production pipeline. This page is for a quick job: a snippet, an inline style block, or an old file you need to read.

Things to watch

  • Whitespace inside strings is collapsed too. A value such as content: "a b" loses its double space. Check generated content and font names written in quotes.
  • Spaces that carry meaning. In a selector, a :hover (any element inside an a while hovered) and a:hover (the link itself) are different. The minifier strips spaces around :, so look at selectors that rely on a space before a colon.
  • License comments are removed. If your CSS begins with a comment you must keep, such as a license notice, put it back after minifying.
  • Keep the original. Minified code is hard to edit. Keep the readable source and treat the minified file as output.

When to use which

Use Beautify when you inherit a one-line stylesheet, copy CSS out of a browser's network panel, or review a vendor file. Use Minify for a small inline block or a quick size check. For a whole site, let the build step do it every time, so no one has to remember.

If your front end is slow to ship or hard to maintain, we can help with web application development and custom website development.

Frequently asked questions

Does my CSS leave my browser?

No. Both Minify and Beautify run in the page on your device, and nothing is sent or stored.

Will minifying change how my page looks?

For ordinary stylesheets, no. The exceptions are the ones listed above: spaces inside quoted strings and selectors that depend on a space before a colon. Compare the page before and after if the stylesheet is unusual.

How much smaller will my file get?

It depends on how much whitespace and how many comments the original has. A heavily commented, generously indented file shrinks the most. A file that is already compact barely changes. Compression on the server (gzip or Brotli) shrinks it further and works together with minifying.

Can it undo minification?

Beautify restores line breaks and indentation, so the code is readable again. It cannot bring back comments, because minifying deleted them, and it does not recover your original formatting choices.

Does it handle SCSS or Less?

It is built for plain CSS. Nested rules and variables from SCSS or Less are not interpreted, so compile them to CSS first.

Related services

Where this topic becomes an engagement.

Keep reading

The articles that follow this one.