whatisgithub

What is purifycss?

akarshsatija/purifycss — explained in plain English

Analysis updated 2026-07-18 · repo last pushed 2016-12-03

JavaScriptAudience · developerComplexity · 2/5DormantSetup · easy

In one sentence

A tool that scans your HTML and JavaScript, finds which CSS classes you actually use, and strips out everything else to shrink your stylesheet file size.

Mindmap

mindmap
  root((repo))
    What it does
      Scans HTML and JS
      Finds used CSS classes
      Removes unused styles
      Writes trimmed output
    Tech stack
      JavaScript
      Node.js
    Use cases
      Shrink Bootstrap CSS
      Speed up page load
      Integrate with build tools
    Audience
      Web developers
      Frontend teams
    Integrations
      Grunt
      Gulp
      webpack

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Shrink a bloated CSS framework like Bootstrap from 140KB down to roughly 35KB by removing unused styles.

USE CASE 2

Speed up website load times without manually auditing every stylesheet by hand.

USE CASE 3

Plug into a Grunt, Gulp, or webpack build pipeline to automatically trim CSS on every build.

What is it built with?

JavaScriptNode.js

How does it compare?

akarshsatija/purifycss3rd-eden/ircb.ioa15n/a15n
LanguageJavaScriptJavaScriptJavaScript
Last pushed2016-12-032016-11-162019-04-07
MaintenanceDormantDormantDormant
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdevelopergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

The CLI version doesn't support file glob patterns, so you must list files explicitly.

So what is it?

PurifyCSS helps you shrink your website's CSS files by removing styles you're not actually using. If you've ever included a CSS framework like Bootstrap, you know that you typically use only a fraction of what it offers, the rest just adds unnecessary weight to your site. This tool looks at your HTML and JavaScript, figures out which CSS classes are actually being referenced, and throws away everything else. The tool works by scanning your project files for class names. It reads through your HTML, JavaScript, PHP, or templates, collects every CSS selector it finds, and then filters your CSS files to keep only the matching rules. It's smart enough to catch classes that are constructed dynamically in JavaScript, for example, if you join string fragments together or use a library like React's classNames to conditionally apply styles. You can use it as a standalone command-line tool, a JavaScript function in your build scripts, or through plugins for popular build tools like Grunt, Gulp, and webpack. This is useful for developers and teams building websites who want faster load times without manually auditing their stylesheets. A concrete example from the README: a Bootstrap CSS file starts around 140KB. Even after standard minification it's still 117KB. But if you run it through this tool first, then minify, you can get it down to roughly 35KB, because you're only keeping the 40% of styles your app actually references. A couple of things worth noting: the tool doesn't modify your original CSS files, so it's safe to experiment with. You write the trimmed output to a new file. You can also whitelist specific selectors if you want to guarantee they survive the cut, useful for classes added dynamically by third-party code that the scanner might miss. The command-line version has one limitation: it doesn't support file pattern matching (like *.js), so you need to list files explicitly when using it that way.

Copy-paste prompts

Prompt 1
Show me how to run PurifyCSS against my HTML and JS files to strip unused CSS from my Bootstrap stylesheet.
Prompt 2
Help me set up PurifyCSS as a webpack plugin so unused styles are removed automatically on build.
Prompt 3
Explain how to whitelist specific CSS classes with PurifyCSS so dynamically-added third-party classes aren't stripped.

Frequently asked questions

What is purifycss?

A tool that scans your HTML and JavaScript, finds which CSS classes you actually use, and strips out everything else to shrink your stylesheet file size.

What language is purifycss written in?

Mainly JavaScript. The stack also includes JavaScript, Node.js.

Is purifycss actively maintained?

Dormant — no commits in 2+ years (last push 2016-12-03).

How hard is purifycss to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is purifycss for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.