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

SelectorResult
.btnKept
.btn-primaryKept
.btn-secondaryKept
.btn-dangerRemoved
.containerKept
.text-centerKept
.hiddenRemoved
.mt-4Kept
Fig. 1 — The sample below, purged552 B → 461 B · −16%

01 — Purge

Paste your code. Keep only the CSS it uses.

209 B
552 B

02 — How it works

Three steps. Your code stays on your side of the line.

  1. 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.

  2. 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.

  3. 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

index.htmlstyles.cssPurgeCSSstyles.purged.css

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.

OptionInputWhat it does
fontFaceOn / offRemoves @font-face rules whose font family no kept rule uses.
keyframesOn / offRemoves @keyframes that no kept animation refers to.
variablesOn / offRemoves custom properties that are declared but never read with var().
rejectedOn / offLists every selector that was removed, so you can spot false positives.
rejectedCssOn / offReturns the removed rules as CSS, ready to compare or restore.
safelist.standardNames, one per lineKeeps selectors by exact name, even when your content does not use them. Write button, not .button.
safelist.deepPatterns, one per lineKeeps selectors that match a pattern, and their children. ^modal keeps .modal .title.
safelist.greedyPatterns, one per lineKeeps a whole selector if any part matches. ^fade keeps .modal.fade.show.
safelist.keyframesPatterns, one per lineKeeps matching @keyframes when keyframes is on.
safelist.variablesNames, one per lineKeeps matching custom properties when variables is on.
blocklistNames, one per lineRemoves selectors by name, even when your content uses them.
dynamicAttributesNames, one per lineKeeps 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 to safelist.standard, or add a pattern to safelist.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.