On this page
Overview
PurgeCSS scans HTML, JavaScript, templates, and other content, compares extracted tokens with CSS selectors, and removes unused rules. It supports CLI, programmatic, PostCSS, Webpack, and other integrations.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Compare content tokens with CSS and remove unused selectors
It scans content files and removes stylesheet selectors that are not represented in the extracted usage set.
Protect dynamic selectors with safelists and custom extractors
Safelists and extractor APIs prevent false removals when static content scanning cannot represent framework or runtime-generated class names.
Choose CLI, PostCSS, Webpack, and other integrations
PurgeCSS can run standalone or inside common frontend build pipelines through dedicated packages and plugins.
Sources: [1]
Best fit
Fits projects with large shared or utility CSS where only a subset is used in production
It is especially useful when deployed CSS contains many selectors that are not referenced by the actual templates or components.
Sources: [1]
Before adoption
Dynamically generated class names may be invisible to static scanning
Classes composed in JavaScript, supplied by CMS content, or generated from runtime state can be removed unless they are covered by safelists or extractors.
Sources: [3]
Version 8 restores default PostCSS-plugin imports and Node 18 support had already been dropped
v8.0.0 changed @fullhuman/postcss-purgecss back to a default import. The v7 changelog states that Node 18 support was dropped, while the v8 purgecss package itself does not declare an engines field.
Official sources
- [1]PurgeCSS v8.0.0 README(2026-10-05)
- [2]PurgeCSS v8 CLI guide(2026-10-05)
- [3]PurgeCSS v8 safelisting guide(2026-10-05)
- [4]PurgeCSS v8.0.0 package metadata(2026-10-05)
- [5]PurgeCSS changelog(2026-10-05)
- [6]PurgeCSS v8.0.0 release(2026-10-05)
- [7]PurgeCSS MIT license(2026-10-05)
Supplemental curator note
PurgeCSS determines usage from content files, so class names created dynamically at runtime may not be visible to static scanning. Protect dynamic selectors with safelists or custom extractors and verify output with regression tests.
Try it in 3 steps
- 1
Install PurgeCSS 8.0.0 in an isolated project
Pin the stable release and test content scanning and unused-selector removal in isolation.
demo=$(mktemp -d "${TMPDIR:-/tmp}/purgecss.XXXXXX") && cd "$demo" && npm init -y >/dev/null && npm install --save-exact --save-dev purgecss@8.0.0 - 2
Create HTML and CSS with used and unused selectors
Prepare one selector referenced by the HTML and one selector that should be removed.
printf "%s\n" '<div class="used">Hello</div>' > index.html && printf "%s\n" '.used { color: green; }' '.unused { color: red; }' > styles.css - 3
Run the CLI and verify the unused selector is gone
Confirm PurgeCSS keeps the referenced selector while removing the unused rule.
mkdir build && npx purgecss --css styles.css --content index.html --output build && grep -q ".used" build/styles.css && ! grep -q ".unused" build/styles.css
Growth
Growth trends · Last 30 days
8,050 Stars
Trend data is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- css
- optimization-tools
- postcss
- postcss-plugin
- purgecss
- rollup-plugin
- webpack-plugin
- Stars
- 8,050
- Forks
- 244
- Watchers
- 55
- Open issues
- 68
- Owner type
- Organization
- Primary language
- TypeScript
- License
- MIT
- Repository last updated
- Aug 20, 2026
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- ts-toolbelt7,150 Stars
3 shared tag(s) · 1 shared category(s) · Same language
reuse 200+ type utilities for advanced Object, Union, Function, and other type computations
TypeScript - Superstruct7,127 Stars
3 shared tag(s) · 1 shared category(s) · Same language
compose small structs to validate JavaScript and TypeScript data at runtime
TypeScript - PostCSS28,974 Stars
4 shared tag(s) · 1 shared category(s) · Same language
parse CSS into an AST and compose build-time style processing with JavaScript plugins
TypeScript - Linaria12,350 Stars
4 shared tag(s) · 1 shared category(s) · Same language
keep CSS-in-JS authoring while extracting styles to static CSS at build time
TypeScript - Panda CSS6,208 Stars
4 shared tag(s) · 1 shared category(s)
scan type-safe style definitions and generate design-token-driven atomic CSS at build time
Rust - Ant Design99,682 Stars
3 shared tag(s) · 1 shared category(s) · Same language
build enterprise React interfaces quickly with ready-made components, design tokens, theming, and internationalization
TypeScript
Report incorrect information
Tell us if any listing information is incorrect or outdated.