Runs in your browser · nothing is uploaded
Remove unused CSS with PurgeCSS.
Paste your HTML, JavaScript and CSS. PurgeCSS finds the selectors your content uses and drops the rest, so you copy back a smaller stylesheet. Your code never leaves this tab.
Works with Bootstrap · Bulma · Foundation · Tailwind CSS · your own CSS
01 — Purge
Paste your code. Keep only the CSS it uses.
02 — How it works
Three steps. Your code stays on your side of the line.
Step 1
Paste your markup and styles
Add the HTML that uses your stylesheet, and JavaScript if it builds class names. Then paste the CSS to clean up.
Step 2 · In your browser
PurgeCSS runs in this tab
The PurgeCSS library is loaded into the page and runs locally. Your code is read in memory and never uploaded.
Step 3
Copy the smaller stylesheet
Copy the purged CSS into your project. Turn on rejected to check what was removed before you ship.
This tab
Our servers only see
An anonymous page view and the request for the PurgeCSS script. No HTML. No CSS. No JavaScript.
03 — Options
Every option matches the PurgeCSS API.
Set them in the Options panel above. The names are the ones the purgecss npm package uses, so a configuration you test here works in your build.
| Option | Input | What it does |
|---|---|---|
| fontFace | On / off | Removes @font-face rules whose font family no kept rule uses. |
| keyframes | On / off | Removes @keyframes that no kept animation refers to. |
| variables | On / off | Removes custom properties that are declared but never read with var(). |
| rejected | On / off | Lists every selector that was removed, so you can spot false positives. |
| rejectedCss | On / off | Returns the removed rules as CSS, ready to compare or restore. |
| safelist.standard | Names, one per line | Keeps selectors by exact name, even when your content does not use them. Write button, not .button. |
| safelist.deep | Patterns, one per line | Keeps selectors that match a pattern, and their children. ^modal keeps .modal .title. |
| safelist.greedy | Patterns, one per line | Keeps a whole selector if any part matches. ^fade keeps .modal.fade.show. |
| safelist.keyframes | Patterns, one per line | Keeps matching @keyframes when keyframes is on. |
| safelist.variables | Names, one per line | Keeps matching custom properties when variables is on. |
| blocklist | Names, one per line | Removes selectors by name, even when your content uses them. |
| dynamicAttributes | Names, one per line | Keeps attribute selectors for attributes set at runtime, such as aria-selected or data-state, whatever their value. |
04 — Questions
Before you purge.
PurgeCSS removes what it cannot find in your content. Test the result in your pages before you ship it.
- What is PurgeCSS?
- PurgeCSS is an open-source tool that removes unused CSS. It reads your content, collects the selectors it uses and drops every rule that matches none of them.
- Is my code uploaded?
- No. PurgeCSS runs in this tab. Your HTML, CSS and JavaScript stay in your browser and are never sent to a server.
- Can I share what I tested?
- Yes. Copy share link puts your HTML, CSS, JavaScript and options into the link, after the #. Browsers never send that part to our servers. Anyone with the link can read the code, so share it as you would share the code itself.
- Why did PurgeCSS remove a class I use?
- PurgeCSS only finds class names written out in full. A class built at runtime, such as
'btn-' + color, is not found. Add it tosafelist.standard, or add a pattern tosafelist.greedy. - What is the difference between the standard, deep and greedy safelists?
- Standard keeps selectors by exact name. Deep keeps a matching selector and its children. Greedy keeps any selector where one part matches the pattern.
- Does it work with Bootstrap or Tailwind CSS?
- Yes. PurgeCSS works with any stylesheet: Bootstrap, Bulma, Foundation, Tailwind CSS or your own. Paste the compiled CSS and the HTML that uses it.
- How do I run PurgeCSS in my build?
- Install the purgecss package from npm and use its CLI, its JavaScript API or the PostCSS plugin. Plugins exist for webpack, Gulp, Grunt and Rollup. The options on this page match the JavaScript API. Export config writes the options from this page as a purgecss.config.mjs or postcss.config.mjs file.
- Is PurgeCSS Online free?
- Yes. It is free and needs no account. PurgeCSS is MIT licensed and maintained by Full Human.