Overview
PurgeCSS is an open-source build tool that strips unused rules out of your stylesheets. It reads your content files, such as HTML, templates and JavaScript, works out which selectors they actually use, and removes everything else from the CSS. On projects built with large frameworks, where only a fraction of the styles are ever used, that can make the shipped stylesheet much smaller.
It is used from the command line, through a JavaScript API, or as a plugin for PostCSS, webpack, Rollup, Gulp, Grunt and Gatsby, so it slots into most front-end build setups. Matching is done by extractors, and you can write your own extractor for a file type the defaults do not handle well.
Because it only sees class names that appear as text in your files, anything built up dynamically at run time can be removed by mistake. The safelist option, by name or by pattern, is how you protect those selectors. PurgeCSS is MIT licensed and maintained by Full Human.
Categories
Features
- Removes CSS selectors that your content files never use
- Command line interface and JavaScript API
- Plugins for PostCSS, webpack, Rollup, Gulp, Grunt and Gatsby
- Safelist selectors by exact name or by pattern
- Custom extractors for any file type
- MIT licensed
Privacy
PurgeCSS runs locally as part of your own build, so your code is not uploaded anywhere. The documentation site itself loads Google Analytics.
Pros & Cons
Pros
- Free and open source
- Fits into most common build tools
- Can cut stylesheet size a lot on framework-heavy sites
- Safelists and custom extractors give control over edge cases
Cons
- A developer tool that needs a Node.js build setup, not a point-and-click app
- Class names generated dynamically in code can be removed unless safelisted
- Needs careful configuration and testing to avoid broken styling
Community Reviews (0)
No written reviews yet — be the first to rate this tool.
Similar Tools
-
CSS · W3C Validators
Checks CSS for errors and standards compliance.
Open Source No Signup Web API -
CSS · CSS-Tricks
Provides tips, tricks, and reference guides for CSS.
Free No Signup Web -
Minifies CSS as part of a PostCSS build pipeline.
Open Source No Signup Web