consolelog.tools

Unused CSS Detector

Paste your HTML and CSS and instantly find selectors that never match the markup. Understands multi-class compounds, descendant/child/sibling combinators, grouped selectors, pseudo-classes and @media blocks, and lets you safelist dynamic classes. Get a usage summary, the list of dead selectors, and a cleaned stylesheet with the unused rules stripped out - all in your browser.

About this ToolHow it works, benefits & use cases

Stylesheets accumulate dead rules as components are renamed or removed, and shipping that bloat slows downloads and parsing. Paste your HTML and CSS here and the detector cross-references them: it parses every selector out of your stylesheet - including the ones inside @media, @supports, @container and @layer blocks - and checks each one against the tags, classes, ids and attributes it finds in the markup. It is selector-aware rather than a blunt text match, so multi-class compounds like .btn.btn--primary, descendant and child combinators like nav > a, sibling combinators and grouped (comma-separated) rules are each evaluated on their own: a selector is only flagged when none of its concrete parts appear in the HTML. Interactive and structural pseudo-classes such as :hover, :focus, :checked and :root ride along with their base selector instead of being wrongly reported, and a safelist input lets you keep classes that only ever appear at runtime - type exact names or a trailing-* wildcard like js-* or modal-*. You get a usage summary (total, used, unused, and the percentage that is dead), an estimated KB saving, the full list of unused selectors, and a cleaned stylesheet with the dead rules removed - including grouped rules trimmed down to just their surviving members. Everything runs in your browser and updates live as you type, or you can switch to run-on-demand for very large stylesheets.

How to Use

  1. 1Paste your HTML markup into the HTML panel, or click Load example to try sample input.
  2. 2Paste the stylesheet you want to audit into the CSS panel.
  3. 3Add any runtime-only classes to the Safelist (comma-separated, with optional trailing-* wildcards) so they are never flagged.
  4. 4Read the summary - Total selectors, Used, Unused, % unused - and the estimated KB saving.
  5. 5Review the Unused selectors list to confirm what will be removed.
  6. 6Copy, download, or pipe the Cleaned CSS, which is your stylesheet with the dead rules stripped out.

Key Benefits

  • Selector-aware: understands compound selectors, combinators, and grouped rules
  • Parses selectors inside @media, @supports, @container and @layer blocks
  • Treats pseudo-classes like :hover, :focus and :checked as used via their base selector
  • Safelist with exact names and trailing-* wildcards for dynamic classes
  • Reports used/unused counts, percent unused, and an estimated KB saving
  • Produces cleaned CSS - grouped rules are trimmed, fully-dead rules removed
  • Runs entirely in the browser; your HTML and CSS are never uploaded

Common Use Cases

  • Trimming legacy CSS after a component or class was renamed or deleted
  • Auditing a static page or email template for unreferenced styles
  • Getting a quick before-you-ship sense of how much of a stylesheet is actually used
  • Generating a cleaned stylesheet to feed into a CSS minifier or build step
  • Reviewing which selectors a small HTML snippet actually exercises
Paste HTML and CSS (or load the example) to see which selectors are unused.

The markup to check selectors against

The stylesheet to audit

Options

Comma-separated class patterns to always keep (e.g. is-active, js-*). A trailing * is a wildcard for dynamically added classes.

Smarter than a plain string match

Compound selectors like .btn.lg, combinators (nav > a), grouped rules and pseudo-classes are all understood: a rule is only flagged when none of its real tags, classes or ids appear in your markup. Interactive states such as :hover ride along with their base selector.

Test before you ship

Detection is based on static HTML, so classes added by JavaScript, frameworks or templates may look unused. Add them to the safelist, and always test after removing CSS. For automated production builds, reach for PurgeCSS.

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related guide

Related tools