Cookies This site keeps only what it needs to work. There is no analytics and no advertising on it today, and nothing here follows you to other sites. Read the privacy policy

Choose what to allow
+92 312 8299940Free Quote
EN – Language: English
Free tool, no account needed

Unused CSS Finder
Find Dead Rules, Then Remove Them

This tool finds the CSS rules that are not being used by any of your web pages or JavaScript. The tool does this by scanning each rule in your CSS file and comparing each rule to all of the rules used in each page of your site. This allows you to find out which rules are completely unused, and so can be deleted. Your entire process takes place in your browser, and no data is stored on our servers.

  • FreePrice
  • ThreeWays in
  • NoneSign-up
  • NothingStored

Unused CSS Finder

Find the rules no page uses, then download the stylesheet without them

One page, or several: start each new page with a line that says <!-- page -->.

The stylesheet to check. Style blocks inside the HTML are read too.

Add your JavaScript (optional, but it makes the result safer)

The finder keeps and labels the classes a script adds later, such as is-open, so it never calls them unused.

Options

One per line or comma: a class name, a name with * in it (btn-*), or a pattern between slashes (/^is-/).

Ready. Add your HTML and CSS, then press Find unused CSS.

Pasted and uploaded code never leaves this tab. Only Scan URL reaches out. The address travels to this site, which downloads the page and its files for you and keeps no copy.
Add a link to this tool on your own site

Copy the code below and drop it into your page. It places a link to this free tool.

The short version

What An Unused CSS Finder Does

Every time you update your website with new features or designs, you’ll likely leave old CSS code in place. This means each person who visits your site will download the CSS for sections of the site that are no longer being displayed.

The un-used CSS tool will answer the question: What CSS rules can we remove from our website and not affect how each page appears? This means that this tool reads your HTML, CSS, and JS files, and then places every CSS rule into four different categories.

First, we read the group. Then, we look at what rules are no longer used by anything. After that, we look at which rules have some selectors in the selector list that can still be matched. After those two steps, we then find the rules that are being kept because they might be needed for a script. Lastly, we find the rules that are now being used on your pages.

The final product is a strategy, not a chance to take risks. There is a justification for every rule, allowing you to review each rule before deleting anything. Then, you may get the pristine stylesheet at once.

How This Unused CSS Finder Reads Your Code

The finder evaluates your CSS in three stages. In the first stage, the finder converts the HTML on your web page into an element tree. Each element in the tree has its classes, ids, and other characteristics. In the second stage, the finder reviews your CSS and breaks down all selector lists into individual selectors. In the third stage, the finder compares each selector to each element.

Diagram of the unused CSS finder: read the HTML, read the CSS, test every selector, then sort the rules into four groups
Read the pages, read the stylesheet, test each selector, then sort every rule.

All five of those things happen within your browser. The reason that the finder has to use its own reader to view the markup is because our site will not allow unsafe methods of viewing the markup. This means that when you paste in some code, or a script, the code will not run and the script will do nothing.

The matching uses actual rules of CSS. For instance, a space indicates descendant, while a greater than symbol (>) indicates child. The :nth-child counts siblings exactly as a browser would. So, if a selector doesn’t find your markup, then it will say that.

Find Unused CSS Across Several Pages

One single page often does not tell the full story. For instance, a check out rule appears to be inactive on the home page, but the check out is dependent on that rule. This is why this tool takes as many pages as you give.

Unused CSS finder report: 6 of 19 rules unused, the size saved, a coverage bar and each unused rule with its reason
Six dead rules, the bytes they cost, and the reason behind each verdict.

You may insert multiple pages into a single box by using a comment line ("page") before each new page. Alternatively, you may upload your own HTML files; every HTML file will count as one page.

Each applied rule gives info about which location it resides at. For example, "applied on 2 of 5 pages" indicates that a particular style exists in only one template. This gives help when you divide your large stylesheet into smaller stylesheets at some point in the future.

Why Checking One Page Falls Short

A most websites use the same style sheet for all of their different template files. If you run a test on just a single web page, then roughly half of the file will appear to be completely unused, even though it actually is. But once you include a product page, a blog entry and a contact form; that’s when the true "dead weight" appears.

Most of all, most cases will boil down to a very basic rule. For each type of page that exists on your site, add at least one page of each type. This is because the finder can check only those pages that it can view.

Classes Your JavaScript Adds Later

The menu opens, the tab changes and the pop-up appears. Each time this happens a script adds a class to the element; so, the class does not exist in the HTML initially. If a tools author is too hasty in determining which rules are "unused", he/she will find that removing the "unused" rules will break the menu.

Kept rules in the unused CSS finder, with .menu.is-open labelled because the pasted script toggles is-open
The menu rule stays, because the script toggles is-open after the page loads.

This finder also reads your scripts. It finds all the strings that appear in those scripts, and it can find each part of a template string. For example, when a script has the name "is-open" inside of it, then the rule for ".menu.is-open" will remain, but with a label rather than being deleted.

Prefixes are also important. For example, if you have a script to build btn--${state}, you will create classes that start with btn--. So, each of the rules associated with those classes remain in place and the reason for them is explained by the label.

Framework bindings get equal attention. The scanner finds Vue, Alpine and Angular class attributes, as well as data attributes and inline event handlers. To summarize, the scanner locates all of the typical locations that create hidden classes.

The Safelist For Everything Else

Some classes come from places no tool can read. For example, a plugin may add them on the server, or an editor may type them by hand. For those, use the safelist.

Every line has either a class name, a name with an asterisk (), or a regex in forward slashes. For example, wp- will keep all classes from WordPress. In addition, the pattern /^is-/ will keep all of your state classes.

Pseudo-Classes, Pseudo-Elements And States

This is where most of the unused css tools get confused. They search for.card::after or.menu summary::before, cannot find an instance of these elements, and then assume that the rule is dead. But a pseudo-element will style some portion of its element. So, if the element is present, the rule is considered used.

Hover and focus state logically follow the exact same process. When a web page initially opens, there is no one who has hovered over, focused on, or selected anything. But within seconds, visitors begin hovering over items and clicking them. So, the states of :hover, :focus, and :checked can be reached.

But structure matters too. For example, li:nth-child(4) on a list that has only three items will never match because you cannot use a single click to create a fourth item. Simply stated, the Finder is only looking for things that might actually match.

An Unused CSS Remover That Keeps Your Formatting

Removing dead rules from your CSS files is just one-half of the process. The other half involves having a clean file that can be shipped. So, this unused CSS remover removes dead rules from the user’s text. It does not rebuild the user’s CSS file.

Cleaned CSS from the unused CSS remover, with dead rules cut out and the original comments and spacing kept
The cleaned stylesheet keeps your formatting, ready to copy or download.

Your comments, spacing and order all stay. When only part of a selector list is dead, just that part goes. Also, the remover drops empty media queries.

Choose the output format. If you want to use the output in your project, make sure it is easy to read. Otherwise, select minify to create a smaller version of the output. When you have chosen which format you want, copy it or download it with the CSV report.

Dead @keyframes, Fonts And Variables

Rules are not the only dead weight. An unused animation, an unused font, and a custom property that no one reads also take up space in bytes. So, the finder will display each of these items on their respective lines.

The checking process begins after the dead rules have been removed. So, the finder finds any fonts that were only used in a dead rule, and then designates those fonts as being unused. A simple plain-text search would not be able to find those fonts.

The scanner can also spot the error when there is a reverse problem. When a rule uses a custom property that has not been defined anywhere, then the scanner will show the error as well. In most cases this indicates a spelling mistake or a missing file.

Fetch A Live Page By Its Address

If you only know the URL of a website, you can enter it here. This site will download the page and its associated stylesheets and scripts. The checks will run on your computer within your web browser just as if you visited the site yourself.

Scan URL mode of the unused CSS finder listing the scanned page, its stylesheets and its scripts with sizes
One address in, and the page arrives with every stylesheet and script it loads.

The fetch is cautious, as it only reads the first @import, ignores external scripts, and limits itself to what it can download without being too large. This means that a tag manager or a chat widget will not cause you to lose valuable time.

This option is best for taking a brief look at someone else’s website. If you are working on your own project, upload/paste all your source files. This will allow you to import each of the templates all at once.

What The Finder Has No Way Of Knowing

No static check sees everything. For example, a class built from a server value, or markup a script loads later, stays hidden. That is why every removal comes with a reason you can read first.

Treat the results as a code review. Check the list of things that weren’t used, add anything you’re going to use to the "safe list," and then test the clean file on a staging site. If you want another perspective, the Coverage panel in Chrome DevTools will tell you how much of the file was used during your last session.

Video guide

The Unused CSS Finder in Action

This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.

How it works

Using The Unused CSS Finder, Step By Step

Four steps take you from a heavy stylesheet to a lean one.

  • Add your pages

    Paste the HTML, upload the files, or type the address of a page.

  • Add your CSS and your scripts

    The finder checks the stylesheet, and your scripts protect the classes they add.

  • Read the verdicts

    Every rule shows its group and its reason, so nothing is a guess.

  • Take the cleaned file

    Copy the result or download it, then test it on a staging copy.

Why this one

What This Unused CSS Finder Does Differently

Safe verdicts, real reasons, and a cleaned file that still looks like yours.

  • It reads your scripts

    The finder keeps the classes a script adds later, and labels them.

  • It gets pseudo-elements right

    A ::before rule counts as used whenever its element exists.

  • It checks many pages

    Add every template, and each rule says how many pages use it.

  • It explains every verdict

    Each rule names the class or the structure that made it dead.

  • It keeps your formatting

    Dead rules are cut out of your own text, and comments stay.

  • Every part of the scan stays in your browser

    Pasted and uploaded code never leaves the tab you are using.

Good habits

Removing Unused CSS Without Breaking A Page

A few habits turn a risky cleanup into a routine one.

  • Feed it every template One page of each kind gives the finder the full picture of your site.
  • Always add the scripts Without them, state classes look dead even though a click adds them.
  • Safelist what comes from the server Plugin and editor classes never appear in a template, so name them once.
  • Test before you ship Put the cleaned file on a staging copy and click through the pages first.
Worth avoiding

Common Mistakes When You Remove Unused CSS

Each of these deletes a rule that a real visitor still needs.

  • Scanning just the home page

    Rules for inner pages look dead when the finder never sees those pages.

  • Leaving the scripts out

    Open menus and active tabs depend on classes that only a script adds.

  • Trusting a tool that ignores ::before

    Icons and decorations vanish when their pseudo-element rules are removed.

  • Forgetting print and dark mode

    Media query rules apply in conditions a quick check rarely tests by eye.

  • Shipping without a test

    A cleaned file is a change like any other, so it deserves one pass on staging.

Questions

Unused CSS Finder FAQ

What does an unused CSS finder do?

It is a tool that compares a stylesheet with the pages that use it. Then it lists every rule that no element matches. So you can remove dead styles, with a clear reason for each one.

Does this unused css finder cost anything?

No. It is free here, needs no account, and you can use it as often as you like.

Is my code sent outside my browser?

When you copy/paste or upload the file, no checks are done. The checking occurs on your browser’s page. The only time we send the URL that you entered is during "fetch" mode. We store no data.

How do I find unused CSS on a whole site?

Each template should include a single page and the same shared stylesheets and scripts. The finder sees all pages as a whole, so rules created on each page are preserved.

Why does the finder keep some rules?

Because you’ve added the class to a script or safelist. Your script will be able to apply this class once the page has loaded. So, removing this rule may cause your menu or pop-up to stop working.

What is meant by partly used?

A set of rules is applied to a selector list, but not all selectors are matched. Thus, the dead selectors are removed by the remover and the remaining selectors are used to apply the rule.

Does it understand :hover and :focus?

Yes. States are counted as being reachable, since a user may select or hover over the element at any point in time. The page’s structure is the sole factor which determines accessibility. So, a failure of a rule will only occur if no element can ever meet its criteria.

Why do other tools flag ::before rules?

Since there is a requirement for "before", which will never exist. But the pseudo-element will style a portion of the element. Thus, the style rule is applied whenever the element itself exists.

Can it read Tailwind classes?

Yes, the escaped names such as md:flex and w-1/2 are working correctly. But a utility file is quite large and would be best cleaned up by a build tool each time there is a release.

Will the finder work with React, Vue or Svelte projects?

Generally speaking, yes. The finder reads the class names from the strings and bindings of each of the component files that you upload. Classes created on the server side are not visible to the finder, so those should be added to the safe list.

What happens to the @media rules?

The finder looks at the rules within just as it would any other rule. If all of the rules within a media query are inactive, then the entire block of code is removed. If there are some active rules remaining, they will remain in the same location.

Does it remove unused @keyframes and fonts?

Yes, by default, it will remove both. If you wish to retain either one, you may deselect that option. It also finds custom properties but will not remove them, as there is the possibility that a script is now using them.

Will the cleaned file keep my comments?

Yes. The remover cuts dead rules out of your own text, so comments, spacing and order all stay. Tick minify only if you want a smaller copy.

Can I check a page just by its address?

Yes. Open the fetch tab and type the address. Then this site downloads the page, up to eight stylesheets and the site's own scripts. After that, the check runs in your tab.

Why did fetch mode skip some scripts?

Most of the time, other websites’ scripts (such as those used for analytics or chat) won’t create classes in your CSS file. Thus, the script finder will ignore these and focus on your code.

Is there a limit on how much CSS I can check?

Yes, about six megabytes of code in one run. Still, a large stylesheet with a few pages takes less than a second on a normal laptop.

How is this different from Chrome Coverage?

Coverage is an indicator of what a user was able to use during their first visit in a single browser state. This tool will check multiple pages, read your scripts, and then give a clean file. This is why the tool and the purger can function together as a unit.

Can I safely delete everything on the list?

Usually, but test first. A static check cannot see classes that come from a server or a later fetch. So a quick test on a staging copy is always worth it.

What is the safelist for?

It protects classes no tool can see. Add a name, a name with a star, or a pattern between slashes. Then every matching rule is kept.

Does removing unused CSS help page speed?

Less CSS results in less data being downloaded, as well as less processing required before displaying the webpage. The "Reduce unused CSS" report on Lighthouse is proof of this.

Can I download a report of the unused selectors?

Yes. The CSV lists each selector with its group, file, line, media query and why. You can use this to share with your team or to submit to a support request.

Does it fix invalid CSS?

No. The browser will keep a selector it cannot understand, for safety reasons. If there are any issues with your grammar, you should run your stylesheet through the <a href="/css-validator/">CSS Validator</a>.

Is an account needed to use the finder?

No. The free tool that finds unused CSS doesn’t need registration or save your data when you exit the page.

More free tools

Handy Companions For Stylesheet Work

There are quite a few other ways to do this. The first would be to use the previous steps as well as those that come after.

Ready To Find Your Unused CSS?

First add your HTML pages, your CSS stylesheet, and your JavaScript files. Next, you will see how each rule applies to each file. This tool is free to use, needs no registration, and will keep your code locally within your browser.

Prefer Denwix on GoogleReview Denwix on Google