CSS Formatter & Minifier

Beautify, minify and tidy CSS in your browser — sort properties, shorten hex, copy.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

A fast, private CSS formatter and minifier that runs entirely in your browser. Paste a stylesheet — however messy — and get back clean, consistently indented CSS, or flip a switch and minify it down to the smallest size for production. It is built for front-end developers tidying a hand-edited stylesheet, reviewers who want a predictable diff, and anyone who has inherited a single-line blob of CSS and needs to actually read it.

How it works

Under the hood the tool runs a small CSS tokenizer rather than a naive find-and-replace. It walks the source character by character, correctly tracking comments, single- and double-quoted strings, and nested parentheses and brackets, so it never splits a declaration in the wrong place — for example inside a url(...) value or a calc() expression. The parser builds a tree of rules (a selector list plus a block) and declarations (a property and a value), and that tree is what gets printed.

When you beautify, each rule opens a brace on its own line, declarations are indented with your chosen unit (2 spaces, 4 spaces or tabs), values are normalised so there is exactly one space after each comma, and optional blank lines separate top-level rules. When you minify, the same tree is printed with no whitespace, declarations joined by semicolons, the final semicolon dropped, and spaces around colons, commas and braces removed. Two extra options work in both modes: sort properties reorders declarations alphabetically within each block (comments and nested rules stay put), and lowercase + shorten hex rewrites #FFAABB style colours to their shortest safe form.

Everything recalculates instantly as you type, the byte-size saving is shown live, and your input plus your options are remembered in this browser so the page is ready next time.

Example

Paste this cramped rule:

.card,.panel{padding:16px;margin:0;border:1px solid #FFAABB;color:#FFF}

Beautified with 2-space indent and hex shortening it becomes a readable block with .card, .panel on the opening line, each property on its own indented line ending in a semicolon, and the colours rewritten to #fab and #fff. Switch to Minify and the same input collapses back to a single tight line with the trailing semicolon removed — typically trimming 20-40% of the bytes from hand-written CSS before any gzip compression is applied on your server.

A @media (max-width: 600px) { ... } block is handled the same way: beautified it is indented one level deeper than its parent rules; minified it becomes @media (max-width:600px){...} with no wasted characters.

Tips

Use beautify while you are writing or reviewing CSS and commit the readable version, then run minify as a build step — or right before pasting into a <style> tag — to ship fewer bytes. Turning on sort properties before you commit makes future diffs far smaller, because changing one value no longer reshuffles surrounding lines. If something looks off, check the notes panel: the parser flags unterminated comments or mismatched braces while still doing its best to format what it could read.

Ad placeholder (rectangle)