ConfigsJul 17, 2026·3 min read

LightningCSS — Ultra-Fast CSS Parser, Transformer, and Minifier

An extremely fast CSS parser, transformer, bundler, and minifier written in Rust, with built-in support for CSS Modules, nesting, and vendor prefixing.

Agent ready

Ready-to-run agent install

This asset can be installed after the agent chooses its runtime, checks the plan, and runs the matching command.

Native · 98/100Policy: allow
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
LightningCSS Overview
Direct install command
npx -y tokrepo@latest install 29c758c9-81dd-11f1-9bc6-00163e2b0d79 --target codex

Run after dry-run confirms the install plan.

Introduction

LightningCSS (formerly Parcel CSS) is a CSS parser, transformer, bundler, and minifier written in Rust. It is designed to be orders of magnitude faster than JavaScript-based CSS tools while providing modern features like automatic vendor prefixing, syntax lowering, and CSS Modules support out of the box.

What LightningCSS Does

  • Parses CSS into a typed AST with full spec compliance and error recovery
  • Minifies CSS with advanced optimizations including shorthand merging and color conversion
  • Automatically adds or removes vendor prefixes based on browser targets
  • Lowers modern CSS syntax (nesting, color functions, custom media queries) for older browsers
  • Supports CSS Modules with scoped class names and composition

Architecture Overview

LightningCSS is built as a Rust library with bindings for Node.js (via NAPI-RS) and a standalone CLI. The parser produces a strongly-typed AST that preserves source maps. Transformations operate on this AST in a single pass where possible, applying browser target lowering, vendor prefixing, and minification together. The minifier performs structural optimizations like merging adjacent rules, collapsing shorthand properties, and converting color formats.

Self-Hosting & Configuration

  • Install the CLI via npm or download prebuilt binaries from GitHub releases
  • Use as a library in Node.js via the lightningcss npm package
  • Integrate with bundlers: native Parcel support, community plugins for Vite and Webpack
  • Configure browser targets using browserslist syntax for automatic prefix and lowering decisions
  • Enable CSS Modules, custom at-rules, or draft specs via API options

Key Features

  • 100x+ faster than cssnano and autoprefixer combined in benchmarks
  • Typed AST means transformations are safe and spec-correct
  • Built-in CSS Modules with composesFrom and scoped naming
  • Handles modern CSS features: nesting, :is(), color-mix(), light-dark(), and more
  • Preserves source maps through all transformations

Comparison with Similar Tools

  • PostCSS + Autoprefixer — plugin-based JS pipeline; LightningCSS is a single Rust binary, far faster
  • cssnano — JS minifier; LightningCSS minifies more aggressively and runs 100x faster
  • esbuild CSS — fast but less complete CSS handling; LightningCSS has deeper CSS spec support
  • Tailwind CSS compiler — utility-class generator; LightningCSS processes standard CSS files
  • sass/less — preprocessors with custom syntax; LightningCSS works with standard CSS and modern specs

FAQ

Q: Can LightningCSS replace PostCSS in my build pipeline? A: For most use cases (prefixing, nesting, minification), yes. If you rely on PostCSS plugins with custom transforms, you may still need PostCSS for those.

Q: Does it support Sass or Less syntax? A: No. LightningCSS processes standard CSS. You would run Sass/Less compilation first, then LightningCSS.

Q: How do I use it with Vite? A: Vite has experimental built-in support for LightningCSS as its CSS transformer via the css.transformer option.

Q: Is the AST API stable for building custom tools? A: The Rust API is well-documented and versioned. The Node.js API mirrors the Rust API with JavaScript-friendly types.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets