Developer Tools

CSS Formatter and Minifier

This tool reindents CSS for reading and compresses it for shipping. The compression is where care is needed: a URL can legally contain the characters that start a comment, and a content string can contain runs of spaces that matter. A minifier that treats the whole file as one long string destroys both, so this one identifies strings and url() values first.

Runs entirely in your browser — nothing you paste is uploaded.

Mode

Reindent so the structure is readable.

Indent

How to

How to use the CSS Formatter

  1. 1

    Paste your CSS

    Type, paste, or load a .css file. The result updates as you type.

  2. 2

    Choose beautify or minify

    Beautify puts each declaration on its own line. Minify strips every unnecessary byte while leaving quoted values alone.

  3. 3

    Decide about comments

    Comments can be removed when minifying. Licence comments beginning /*! are kept regardless, which is the usual convention.

  4. 4

    Copy the result

    The byte counts show what you saved. Copy the output or download it as a file.

Examples

CSS Formatter examples

A URL containing a comment marker

Input
.a { background: url("http://x.com/a/*b*/c.png"); }
Output
.a{background:url("http://x.com/a/*b*/c.png")}

A minifier that strips anything between /* and */ removes the middle of this URL and leaves a broken path. Recognising url() as a unit prevents that.

A content string

Input
.a::before { content: "a b"; }
Output
.a::before{content:"a b"}

Those spaces are rendered on the page, so collapsing them changes the design. Quoted strings are copied through unchanged.

A licence header

Input
/*! MIT licensed */ .a { color: red; }
Output
/*! MIT licensed */.a{color:red}

The /*! form conventionally marks a comment that must survive minification for licensing reasons, so it is kept while ordinary comments go.

Why use it

What the CSS Formatter gives you

Values are never corrupted

Quoted strings and url() values are identified before any whitespace or comment removal, so their contents come through byte for byte.

Licence comments survive

The /*! convention is respected, so minifying does not strip an attribution you are required to keep.

Real savings, shown

Byte counts before and after tell you whether the minification was worth doing for this particular file.

Runs in your browser

Unreleased stylesheets are not uploaded anywhere, and the tool works with no network connection.

Good to know

CSS Formatter limitations

  • This removes whitespace and comments. It does not merge duplicate rules, shorten colours or drop unused selectors.
  • Vendor prefixes are neither added nor removed — use a build step with a browser support target for that.
  • CSS with syntax errors is passed through as-is rather than corrected, since guessing intent would be worse.
  • Very large stylesheets are held in memory and may be slow.

Summary

CSS Formatter in short

  • url() values and quoted strings are protected from the minifier.
  • Licence comments starting /*! are kept while ordinary comments are removed.
  • Minification here is whitespace and comments only, not rule optimisation.
  • The redundant semicolon before each closing brace is dropped.
  • Everything runs in your browser.

FAQ

CSS Formatter questions

Why do some minifiers break background images?

Because a URL can contain the sequence that opens a CSS comment. Stripping everything between /* and */ across the whole file removes part of the path, leaving a request for an image that does not exist.

Are spaces inside a content property preserved?

Yes. Anything in quotes is rendered literally on the page, so collapsing whitespace there changes what the user sees. Quoted values are copied through untouched.

How do I keep a licence header when minifying?

Start it with /*! rather than /*. That convention is understood by most minifiers, including this one, and marks a comment that must survive because it carries attribution you are obliged to keep.

How much smaller does minified CSS get?

Typically 20 to 30 percent for hand-written CSS with normal indentation and comments. Generated or already-compact stylesheets save far less, which is why the byte counts are shown rather than assumed.

Does it merge duplicate rules or shorten colours?

No. Those transformations change the cascade or rely on knowing which browsers you support, so they belong in a build step with proper configuration rather than in a quick browser tool.

Is it safe to remove the last semicolon in a block?

Yes. The semicolon separates declarations, so the one before a closing brace is optional. Removing it is a small, entirely safe saving that every minifier makes.

Can I format Sass or Less with this?

Only partly. Nesting and variables are not CSS syntax, so the beautifier will not indent them meaningfully. Compile to plain CSS first, then format the output.

What happens if my CSS has a mistake in it?

It passes through rather than being silently repaired. A minifier guessing at what a malformed rule meant would be far more dangerous than leaving it visible for you to fix.

Does my stylesheet get uploaded?

No. Both formatting and minification happen in this page, so an unreleased design system stays entirely on your machine.

Discover

Related developer tools