CSS Minifier and Beautifier
A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call
Free CSS minifier. Compress CSS by removing comments and spaces safely, or beautify minified CSS into readable code. Shows how much you saved.
- Before
- 0
- After
- 0
- Saved
- 0
Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.
How to use the CSS minifier
Paste your CSS, and the CSS minifier compresses it instantly. You'll see the size before and after and how much smaller it is. Copy the result and use it in your site.
Switch to Beautify to do the opposite: turn minified or messy CSS into neatly indented, readable code, with one declaration per line.
Option: Keep /*! license */ comments. Comments starting with /*! usually hold licence notices that must stay with the code; the CSS minifier keeps them unless you turn this off. All other comments are removed.
Everything runs in your browser, and your code is never uploaded.
What CSS minification does
Minifying removes everything the browser doesn't need, without changing what the CSS does:
- Comments.
- Line breaks and indentation.
- Spaces around
{,},:,;,,and>,+,~combinators. - The last semicolon in each rule, before
}.
So this:
/* Buttons */
.button {
color : #ffffff ;
padding: 12px 20px;
}
becomes this:
.button{color:#ffffff;padding:12px 20px}
Safe minification: what it doesn't touch
A careless minifier can break CSS. This CSS minifier is careful about the places where spaces matter:
- Strings: anything inside quotes, such as
content: "a ; b", stays exactly as written. - calc() and other functions:
calc(100% - 32px)needs the spaces around-and+. Spaces inside brackets are kept as single spaces. - Descendant selectors:
div :first-child(any first child inside a div) means something different fromdiv:first-child, so a space before a colon in a selector is kept. - Media queries:
@media screen and (max-width: 600px)keeps the space before the bracket, which the query needs. - Data URIs and url(): unquoted
url(data:image/png;base64,…)values keep their semicolons.
It doesn't do riskier "optimisations" either, such as rewriting colours, merging rules or removing units from zero values, because in some contexts (inside calc(), for example) these change how CSS behaves.
How much does minifying save?
For typical hand-written CSS with comments and indentation, minifying saves 15% to 30% of the file size; heavily commented files save more. On top of that, your server should compress files with gzip or Brotli when it sends them, which typically shrinks CSS by a further 70% to 85%. Minifying and compression work together: minify first, then let the server compress.
Why size matters
CSS blocks rendering: the browser won't show the page until it has downloaded and read the CSS. Smaller CSS means a faster first view, which helps visitors on slow connections and helps your Core Web Vitals scores, which Google uses as a ranking signal.
Beautifying CSS
Beautify mode formats CSS for reading and editing:
- one declaration per line,
- two-space indentation, including inside
@mediablocks, - a space after each colon in declarations,
- selectors on one line, with commas followed by a space,
- a blank line between top-level rules.
It's useful for reading a theme's minified CSS, debugging a problem, or tidying CSS copied from several places.
Other ways to make CSS faster
- Remove unused CSS. Themes and frameworks often ship far more CSS than a page uses. Browser developer tools have a "Coverage" panel that shows unused CSS.
- Inline critical CSS for the top of the page, and load the rest later.
- Avoid
@importinside CSS files, which makes the browser fetch files one after another. - Use a build tool for larger sites: tools such as Lightning CSS, cssnano and esbuild minify automatically when you publish.
- Cache CSS for a long time and change the file name or a version number when it changes.
- Use rem units for font sizes, which respect visitors' font settings; the px to rem converter converts sizes.
When to use an online CSS minifier
An online CSS minifier is ideal for:
- Small sites without a build process, such as a simple HTML site or a landing page.
- CSS added through a CMS, such as custom CSS in WordPress, Shopify or Squarespace settings.
- Email templates, where file size affects whether emails get clipped.
- Quick checks before you set up a proper build process.
Keep your original, readable CSS file for editing, and minify a copy for the live site. Never edit minified CSS directly: beautify it, edit, then minify again.
Checking your colours and contrast
While you're working on CSS, check your colours are readable: the color contrast checker tests text against its background for accessibility, and the HEX to RGB converter converts between colour formats. For other web jobs, the JSON formatter, HTML table generator and Markdown to HTML converter help.
Page speed and SEO
Fast pages are part of a good experience, and speed is one of many signals search engines consider. But content matters more: a fast page with thin content won't rank.
Minifying CSS in WordPress, Shopify and other platforms
- WordPress: custom CSS added under Appearance → Customize → Additional CSS can be minified here before pasting. Many caching plugins can also minify theme CSS automatically.
- Shopify: theme CSS files can be edited under Online Store → Themes → Edit code; keep a readable copy and paste a minified version for the live theme, or use a theme that already ships minified CSS.
- Squarespace and Wix: paste minified CSS into the custom CSS panel.
- Static sites: keep a readable style.css for editing and publish a minified style.min.css.
Whichever platform you use, check every page after changing CSS: forms, menus on mobile, and pages you don't visit often.
Readable source, minified output
The golden rule of minifying: keep the readable version as your source. Comments explain why a rule exists; indentation shows structure. You'll need both the next time you change something. Minify a copy for the live site, and if you ever find yourself with only a minified file, use Beautify mode to make it editable again (comments that were removed can't be recovered, though).
Other ways to shrink CSS
Beyond what the CSS minifier does, a few manual changes can save more:
- Remove rules for features you no longer use. Old campaign styles and unused components add up.
- Combine duplicate rules. Two rules for the same selector can usually be merged.
- Use shorthand properties: margin: 0 auto instead of four separate margin properties.
- Avoid deep selectors like .page .content .post .title a; they're longer and slower to match.
- Use system fonts or fewer font weights; every web font file adds far more than any CSS saving.
Use CSS custom properties (variables) for colours and spacing, so changes happen in one place.
Checking that minified CSS works
After minifying, test before you publish:
- Open the site in a private window, so old cached CSS isn't used.
- Check key pages: home, a product or blog page, a form and the checkout or contact page.
- Check on a phone, where media queries apply.
- Look for console errors in the browser's developer tools.
- Compare with the original side by side if anything looks different.
If something breaks, beautify the minified CSS and compare it with your original to find the rule that changed. With a careful CSS minifier like this one, problems are rare, but a quick check takes two minutes and avoids surprises.
Does minified CSS affect SEO directly?
Search engines read minified and unminified CSS the same way. The benefit is indirect: smaller files load faster, which improves the experience for visitors and the speed signals search engines measure. Minifying won't fix slow images or heavy scripts, which usually matter more, so treat it as one step in making a page fast.
A worked example
A bakery's website uses a theme with a 48 KB custom stylesheet, full of comments and indentation, added through the site builder's "custom CSS" box. The owner pastes it into the CSS minifier: the result is 35 KB, 27% smaller. They keep the original in a "website" folder for future edits, paste the minified version into the site builder, and check every page still looks right. Combined with compressed images, the homepage now loads noticeably faster on phones.
Need more customers from Google?
This tool is free and runs in your browser. If your business also needs more leads or sales, Google Ads is where people search with their wallet out. DeepRit manages Google Ads for small and mid-size businesses, and only Google Ads. We check your account before we ever get on a call, then fix the structure, the keywords, the tracking and the ads, with month-to-month terms and no long contract. Book a free audit call.
Frequently asked questions
What does a CSS minifier do?
It removes comments, line breaks and unnecessary spaces from CSS, so the file is smaller but works exactly the same.
Can minifying break my CSS?
A careless minifier can. This one keeps strings, spaces inside calc(), descendant selectors and media queries intact, and avoids risky rewrites.
How much smaller will my CSS be?
Typically 15% to 30% for hand-written CSS, and more if it has lots of comments.
How do I make minified CSS readable?
Choose Beautify. It formats the CSS with indentation and one declaration per line.
Should I minify CSS if my server uses gzip?
Yes. Minifying and compression work together, and minified CSS also takes less memory for the browser to read.
Is the CSS minifier free?
Yes. It's free with no sign-up, and your code never leaves your browser.
Free PPC audit
See where your ad budget leaks.
We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.