tinyparrot: autoprefix + minify + dedupe + optional purge
npm install tinyparrotbash
npm install --save-dev css-optimizer
`
or
`bash
pnpm add -D css-optimizer
`
or
`bash
yarn add -D css-optimizer
`
Global (optional)
`bash
npm install -g css-optimizer
`
CLI Usage
$3
`bash
npx tinyparrot --in styles.css --out styles.min.css
`
This will:
* add vendor prefixes
* remove duplicate rules
* minify the CSS
$3
`bash
npx css-optimizer --in styles.css > styles.min.css
`
$3
`bash
npx css-optimizer --in styles.css --out styles.min.css \
--no-autoprefix \
--no-minify
`
Available disable flags:
* --no-autoprefix
* --no-minify
* --no-dedupe
$3
`bash
npx css-optimizer --in styles.css --out styles.min.css --sort
`
⚠️ Property sorting may cause large diffs in version control.
$3
PurgeCSS removes selectors that are not found in your HTML / JS / Vue / React files.
#### Example
`bash
npx css-optimizer \
--in styles.css \
--out styles.purged.css \
--purge \
--content "src/*/.{html,js,ts,tsx,vue}"
`
Important notes
* When --purge is enabled, --content is required
* PurgeCSS runs before minification
Safelist (dynamic selectors)
If your project uses dynamically generated class names:
`bash
npx css-optimizer \
--in styles.css \
--out styles.purged.css \
--purge \
--content "src/*/.{html,js,vue}" \
--safelist active open modal
`
> CLI safelist supports strings only.
>
> The API supports both strings and RegExp.
CLI Options
| Option | Description |
| ----------------------- | -------------------------------- |
| --in | Input CSS file (required) |
| --out | Output file (defaults to stdout) |
| --no-autoprefix | Disable autoprefixer |
| --no-minify | Disable minification |
| --no-dedupe | Disable duplicate removal |
| --sort | Sort CSS properties |
| --purge | Enable PurgeCSS |
| --content | Files to scan for used selectors |
| --safelist | Safelisted selectors |
Node.js API
$3
`bash
import { optimizeCss } from "css-optimizer";
const inputCss =
;
const { css } = await optimizeCss(inputCss);
console.log(css);
`
$3
`bash
import { optimizeCss } from "css-optimizer";
const { css } = await optimizeCss(inputCss, {
autoprefix: true,
minify: true,
dedupe: true,
sort: false,
purge: true,
content: ["src//.html", "src//.js"],
safelist: ["active", /^modal-/]
});
`
API Options
`bash
optimizeCss(css, {
from?: string,
to?: string,
autoprefix?: boolean,
minify?: boolean,
dedupe?: boolean,
sort?: boolean,
purge?: boolean,
content?: string[],
safelist?: (string | RegExp)[]
})
`
Typical Use Cases
* 📦 Preparing CSS for production
* ⚡ Asset optimization in CI pipelines
* 🧹 Cleaning up utility-heavy CSS (e.g. Tailwind)
* 🏗 Integration with Vite, Webpack, Nuxt, Next.js
* 🧪 One-off CSS optimization scripts
Browser Support
Browser compatibility depends on autoprefixer and browserslist.
If your project defines a browserslist` configuration, it will be picked up automatically.