CSS Crunch Logo

CSS Crunch

A lightning-fast, ultra-efficient TypeScript library for optimizing and compressing CSS strings.

Node.js 22-26
Module NodeNext
ESM & CommonJS
Try the Playground

Features

Installation & Usage

Installation

npm install @gafreax/csscrunch

CLI Usage

npx @gafreax/csscrunch compile input.css optimized.css

Library Usage (ESM)

import csscrunch from '@gafreax/csscrunch'
const { default: compile } = csscrunch

const cssString = '.example { color: red; font-size: 16px; }';
const parsedCSS = compile(cssString);

Library Usage (CommonJS)

const csscrunch = require('@gafreax/csscrunch')
const { default: compile } = csscrunch

const cssString = '.example { color: red; font-size: 16px; }';
const parsedCSS = compile(cssString);

Performance Comparison

CSS Crunch is built for unparalleled performance. Below is a direct benchmark comparison against clean-css, showcasing superior throughput and compression efficiency.

🚀 Throughput Benchmark

Higher is better (operations per second)

View Full Chart

📦 Size Benchmark

Lower is better (KB)

View Detailed Size Report

Toolchain Performance

CSS Crunch keeps its developer toolchain fast and modern. Type-checking runs on TypeScript 7 via tsgo (the native Go compiler), while bundling and dual CJS/ESM output are handled by tsdown (built on Rolldown, in Rust). Measured on this repository:

Type-check --noEmit

~3.4× faster

~0.34 s with tsc 6.0.3 → ~0.10 s with tsgo

Build & bundling

tsdown

Rolldown (Rust) — dual CJS/ESM output with .d.ts

tsgo reports the same type errors as tsc. TypeScript 7 is still in preview, so it is used for type-checking only (which emits nothing); the published declaration files are generated by the stable TypeScript compiler, with the native tsgo path kept opt-in until TS 7 is stable.