# postcss-minify-selectors

> Minify selectors with PostCSS.

Latest version **9.0.4** (published 2026-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-minify-selectors
pnpm add postcss-minify-selectors
yarn add postcss-minify-selectors
bun add postcss-minify-selectors
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 9.0.4 |
| Published | 2026-09-17 |
| First published | 2015-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^22.22.3 \|\| ^24.15.0 \|\| >=26.0 |
| Dependencies | 4 |
| Unpacked size | 35.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 4978 |
| Author | Ben Briggs |
| Maintainers | beneb, trysound, ludovicofischer, ai, chriseppstein, andyjansson, evilebottnawi, cssnano-bot |
| Keywords | css, minify, optimise, postcss, postcss-plugin, selectors |

## Links

- npm: https://www.npmjs.com/package/postcss-minify-selectors
- Repository: https://github.com/cssnano/cssnano
- Issues: https://github.com/cssnano/cssnano/issues
- npm.io page: https://npm.io/package/postcss-minify-selectors

## Dependencies (4)

- [cssesc](https://npm.io/package/cssesc.md) ^3.0.0
- [caniuse-api](https://npm.io/package/caniuse-api.md) ^4.0.0
- [browserslist](https://npm.io/package/browserslist.md) ^4.29.0
- [postcss-selector-parser](https://npm.io/package/postcss-selector-parser.md) ^7.1.6

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 9.0.4 (latest) — 2026-09-17
- 5.0.0-rc.2 (next) — 2021-03-15
- 4.0.0-nightly.2020.2.6 (nightly) — 2021-02-06
- 9.0.3 — 2026-09-05
- 9.0.2 — 2026-09-01
- 9.0.1 — 2026-08-28
- 9.0.0 — 2026-08-27
- 8.0.5 — 2026-08-16
- 8.0.4 — 2026-08-09
- 8.0.3 — 2026-08-04
- 8.0.2 — 2026-06-11
- 8.0.1 — 2026-05-08
- 8.0.0 — 2026-05-06
- 7.1.2 — 2026-05-04
- 7.1.1 — 2026-05-02
- … 68 more at https://npm.io/package/postcss-minify-selectors/versions

## README

# [postcss][postcss]-minify-selectors

> Minify selectors with PostCSS.

## Install

With [npm](https://www.npmjs.com/package/postcss-minify-selectors) do:

```
npm install postcss-minify-selectors --save
```

## Example

### Input

```css
h1 + p, h2, h3, h2{color:blue}
```

### Output

```css
h1+p,h2,h3{color:blue}
```

For more examples see the [tests](test/index.js).

## Options

### `sort`

Type: `boolean`  
Default: `true`

Alphabetically sort selectors within a comma-separated list.

### `convertToIs`

Type: `boolean`  
Default: `true`

Factor a shared prefix and/or suffix in a comma-separated selector list into
a single `:is(...)` group when the result is strictly shorter and safe with
respect to the cascade. The rewrite only applies when every variable part
has the same CSS specificity (so the cascade isn't silently altered) and
contains no pseudo-elements. It is automatically skipped when the configured
`browserslist` target doesn't support `:is()`.

#### Input

```css
section h1, article h1, aside h1, nav h1 { font-size: 25px }
```

#### Output

```css
:is(article,aside,nav,section) h1{font-size:25px}
```

### Browserslist

The plugin reads the `browserslist` configuration from the host project by
default. You can override with `overrideBrowserslist`, `stats`, `env`, or
`path` — the same options accepted by `autoprefixer` and `postcss-merge-rules`.

## Usage

See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
examples for your environment.

## Contributors

See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/main/CONTRIBUTORS.md).

## License

MIT © [Ben Briggs](https://beneb.info)

[postcss]: https://github.com/postcss/postcss

---
_Source: https://npm.io/package/postcss-minify-selectors · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
