Remove Unused CSS from HTML and CSS Input

This free online tool analyzes your HTML and CSS inputs and removes unused styles from the CSS reducing the file size without impacting the reult.

Demo:

Removed selectors


						

Cleaned CSS

Preview (Original)

Preview (Cleaned)

Remove Unused CSS

Our free online tool analyzes your HTML and CSS stylesheet, then safely strips selectors that aren't used, shrinking files and speeding up render times without changing your HTML.

This tool is available at GitHub PurgeCSS.

It’s especially helpful when you use frameworks or UI kits that ship thousands of default rules. Use the safelist to keep any dynamic classes added at runtime with JavaScript for example. The "before-after" live preview lets you compare the original rendering and the cleaned result side-by-side. When you’re satisfied, copy the cleaned CSS styles.

10 - 90%
Typical CSS size reduction
⏱️
Faster render & LCP
0 HTML
No HTML edits required

Why use it?

  • Frameworks offer big CSS but your project usually use a small part of it.
  • Purge keeps what's used, discards the unnecessary fluff.
  • Smaller downloads, faster render, simpler maintenance.

How it works

  1. Parses your content for class, id, and tag usage.
  2. Compares findings to your CSS selectors.
  3. Removes rules that are't used. Optionally safelist dynamic selectors.

Under the hood

Scan Content

HTML, templates, and components are scanned for used selectors.

Match Selectors

Only rules referenced in your content are kept.

Purge & Output

Unused rules are removed; the result is your lean CSS.

Tips for best results

Safelist runtime toggles

Keep classes added by scripts or states you still need (e.g., .open, .is-active).

Scope by page

Group CSS per page or route to maximize the reduction effect.

Verify removals

Review the Removed selectors list so nothing critical is stripped.

Parts of The Dashboard

HTML
<button class="btn">
Buy now</button>
CSS (before)
.btn { padding: .75rem 1rem; }
.btn--alt { opacity: .7; }
.card { 
  box-shadow: 0 2px 6px #2F2); 
}
CSS (after purge)
.btn { padding: .75rem 1rem; }

Using dynamic classes?
Add them to a safelist to prevent their removl.

Do

  • Clean up CSS to all your real content paths.
  • Safelist classes generated by JS/frameworks.
  • Compress your styles with the CSS editor.

Don't

  • Purged global utility classes you still toggle.
  • Forget to style dynamically inserted content.
  • Ship both full and purged CSS to prod.

Remove Unused CSS