Heat map at a glance
Every selector is scored and painted hot-to-cool, sorted most-specific-first. The
selectors that cause your !important wars rise to the top in red.
Specificity is invisible until something breaks. This CLI makes it legible — point it at a file, a whole project, or a live URL and every selector is scored and color-coded, with the over-specific offenders glowing red.
$ pnpm add -g css-specificity-cli
View on GitHub
Three things it does that a linter rule buried in a config never quite does.
Every selector is scored and painted hot-to-cool, sorted most-specific-first. The
selectors that cause your !important wars rise to the top in red.
--threshold 0,3,0 exits non-zero the moment a selector gets too specific —
so specificity creep fails the build instead of shipping.
Point it at one .css file, a whole project directory, or a live
https:// URL — it pulls in every linked and inline stylesheet and reports
on all of them together.
Node 18+. Install it globally, or run it on demand with no install.
$ pnpm add -g css-specificity-cli # or, without installing anything: $ pnpm dlx css-specificity-cli styles.css
The handful of invocations you’ll actually reach for.
Print the full heat map, hottest selectors first.
$ css-specificity styles.cssWalk a directory and report on every .css file at once.
$ css-specificity ./srcFetch a page and score every stylesheet it loads. Add --browser to capture runtime CSS-in-JS.
$ css-specificity https://example.comFail the build if any selector is more specific than two classes.
$ css-specificity styles.css --threshold 0,2,0Show only the ten most specific selectors.
$ css-specificity styles.css --top 10Read CSS straight off a pipe and emit JSON.
$ cat styles.css | css-specificity - --json