# postcss-nested

> PostCSS plugin to unwrap nested rules like how Sass does it

Latest version **8.0.1** (published 2026-08-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-nested
pnpm add postcss-nested
yarn add postcss-nested
bun add postcss-nested
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 8.0.1 |
| Published | 2026-08-02 |
| First published | 2014-11-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^22.0.0 \|\| ^24.0.0 \|\| >= 26.0.0 |
| Dependencies | 1 |
| Unpacked size | 14.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1197 |
| Author | Andrey Sitnik |
| Maintainers | ai |
| Keywords | css, nested, postcss, postcss-plugin, sass |

## Links

- npm: https://www.npmjs.com/package/postcss-nested
- Repository: https://github.com/postcss/postcss-nested
- Homepage: https://github.com/postcss/postcss-nested#readme
- Issues: https://github.com/postcss/postcss-nested/issues
- Funding: https://opencollective.com/postcss/
- npm.io page: https://npm.io/package/postcss-nested

## Dependencies (1)

- [postcss-selector-parser](https://npm.io/package/postcss-selector-parser.md) ^7.1.4

## 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

- 8.0.1 (latest) — 2026-08-02
- 8.0.0 — 2026-07-29
- 7.0.2 — 2024-11-01
- 7.0.1 — 2024-10-31
- 7.0.0 — 2024-10-29
- 6.2.0 — 2024-07-19
- 6.0.1 — 2023-02-19
- 6.0.0 — 2022-10-06
- 5.0.6 — 2021-07-28
- 5.0.5 — 2021-03-05
- 5.0.4 — 2021-02-26
- 5.0.3 — 2020-12-08
- 5.0.2 — 2020-12-03
- 5.0.1 — 2020-09-27
- 5.0.0 — 2020-09-15
- … 26 more at https://npm.io/package/postcss-nested/versions

## README

# PostCSS Nested

<img align="right" width="135" height="95"
     title="Philosopher’s stone, logo of PostCSS"
     src="https://postcss.org/logo-leftp.svg">

[PostCSS] plugin to unwrap nested rules closer to Sass syntax.

```css
.phone {
  &_title {
    width: 500px;
    @media (max-width: 500px) {
      width: auto;
    }
    body.is_dark & {
      color: white;
    }
  }
  img {
    display: block;
  }
}

.title {
  font-size: var(--font);

  @at-root html {
    --font: 16px;
  }
}
```

will be processed to:

```css
.phone_title {
  width: 500px;
}
@media (max-width: 500px) {
  .phone_title {
    width: auto;
  }
}
body.is_dark .phone_title {
  color: white;
}
.phone img {
  display: block;
}

.title {
  font-size: var(--font);
}
html {
  --font: 16px;
}
```

Related plugins:

- Use [`postcss-current-selector`] **after** this plugin if you want
  to use current selector in properties or variables values.
- Use [`postcss-nested-ancestors`] **before** this plugin if you want
  to reference any ancestor element directly in your selectors with `^&`.

Alternatives:

- See also [`postcss-nesting`], which implements [CSSWG draft].
- [`postcss-nested-props`] for nested properties like `font-size`.

---

<img src="https://cdn.evilmartians.com/badges/logo-no-label.svg" alt="" width="22" height="16" />  PostCSS Nested is built by <b><a href="https://evilmartians.com/">Evil Martians</a></b>, an American design and engineering consultancy for <b>developer tools, AI, and cybersecurity startups</b>.

---

[`postcss-current-selector`]: https://github.com/komlev/postcss-current-selector
[`postcss-nested-ancestors`]: https://github.com/toomuchdesign/postcss-nested-ancestors
[`postcss-nested-props`]: https://github.com/jedmao/postcss-nested-props
[`postcss-nesting`]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting
[CSSWG draft]: https://drafts.csswg.org/css-nesting-1/
[PostCSS]: https://github.com/postcss/postcss

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