PostCSS plugin that removes selectors from your CSS.

View on GitHub


Package Version Dependency Status

PostCSS plugin that removes selectors from your CSS.


To use it, simply create a new instance of the plugin passing a list of selectors you want to be removed from your CSS.

Entries of the list can be either strings or regular expression. In both cases, search will match all selectors starting with the selector.

If a rule matches only that selector, the rule will be removed entirely, otherwise only the matching selector will be removed.


Given this plugin configuration:

const fs = require("fs");
const postcss = require("postcss");
const removeSelectors = require("postcss-remove-selectors");

const css = fs.readFileSync("input.css", "utf8");
const output = postcss().use(removeSelectors({selectors: ["a"]})).process(css).css;

the following CSS

strong, a{
  font-weight: bold;

  color: red;

will be transformed to this CSS

  font-weight: bold;

Supported implementations.

postcss-remove-selectors supports and has been tested on NodeJS 6.0+.

Contributing to postcss-remove-selectors


Copyright (C) 2017 and above Shogun

Licensed under the MIT license, which can be found at

Your browser is obsolete. For the best browsing experience, update it for free by visiting BrowseHappy.
There is a shiny new version. Update now!
Made by a proud Italian!