OSS TanbouSign in with GitHub

compose preset-driven PostCSS optimizations to minify production CSS

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
4,978
Primary language
CSS
License
MIT
Repository last updated
Oct 5, 2026
On this page

Overview

cssnano is a modular CSS minifier built on the PostCSS ecosystem. Presets combine color compression, comment removal, rule cleanup, descriptor normalization, and other optimizations for production builds.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Apply a safe-oriented bundle of optimizations with the default preset

The default preset groups transforms intended to be safe for normal CSS so teams do not need to configure every minification plugin individually.

Sources: [1][2]

Compress more than whitespace

Optimizations include shorter colors, comment removal, discarding overridden at-rules, normalizing descriptors such as unicode-range, and other CSS-aware transforms.

Sources: [1]

Choose presets with different optimization aggressiveness

The project distinguishes the default preset from options such as advanced, allowing teams to select stronger transforms when project requirements permit them.

Sources: [1]

Best fit

Fits production builds that want CSS size reduction inside an existing PostCSS pipeline

It can sit alongside plugins such as Autoprefixer and perform final CSS minimization before deployment.

Sources: [1][2]

Before adoption

Version 9.3.1 requires a recent Node runtime

Package metadata requires Node ^22.22.3 || ^24.15.0 || >=26.0, so Node 20 and older Node 22 releases do not satisfy the declared engine range.

Sources: [2]

Advanced presets require project-specific validation

The README describes the advanced preset as more aggressive and safe only when site requirements are met. Validate visual and functional output before switching from the default preset.

Sources: [1]

Official sources

  1. [1]cssnano 9.3.1 README(2026-10-05)
  2. [2]cssnano 9.3.1 package metadata(2026-10-05)
  3. [3]cssnano 9.3.1 release(2026-10-05)
  4. [4]cssnano MIT license(2026-10-05)
Supplemental curator note

cssnano 9.3.1 requires PostCSS ^8.5.28 and Node ^22.22.3 || ^24.15.0 || >=26.0. CI still running Node 20 or an older Node 22 release must be upgraded first.

Try it in 3 steps

  1. 1

    Install cssnano 9.3.1 with PostCSS

    Pin the stable release on a supported Node.js runtime: ^22.22.3 || ^24.15.0 || >=26.0.

    demo=$(mktemp -d "${TMPDIR:-/tmp}/cssnano.XXXXXX") && cd "$demo" && npm init -y >/dev/null && npm install --save-exact postcss@8.5.29 cssnano@9.3.1
  2. 2

    Create CSS and a script using the default preset

    Use the default preset on input that can demonstrate color, zero-value, and whitespace optimizations.

    printf "%s\n" '.card { color: #ff0000; margin: 0px 0px 0px 0px; }' > input.css && printf "%s\n" "import fs from 'node:fs';" "import postcss from 'postcss';" "import cssnano from 'cssnano';" "const css = fs.readFileSync('input.css', 'utf8');" "const result = await postcss([cssnano({ preset: 'default' })]).process(css, { from: 'input.css', to: 'output.css' });" "fs.writeFileSync('output.css', result.css);" > demo.mjs
  3. 3

    Minify the stylesheet and inspect the result

    Confirm that CSS-aware optimizations were applied and that the output is smaller than the input.

    node demo.mjs && grep -Eq '(red|#f00)' output.css && test "$(wc -c < output.css)" -lt "$(wc -c < input.css)"
Check the official README

Growth

Growth trends · Last 30 days

4,978 Stars

Trend data is still being collected.

Built with

Categories and tags

Categories

GitHub data

GitHub dataView detailed GitHub data

GitHub Topics

  • css
  • cssnano
  • minification
  • optimisation
  • postcss
Stars
4,978
Forks
330
Watchers
49
Open issues
29
Owner type
Organization
Primary language
CSS
License
MIT
Repository last updated
Oct 5, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?