# Lightning CSS — card for AI agents

High-performance CSS parser and minifier written in Rust, with modern CSS feature support.

Category: Styling and CSS · npm package `lightningcss` · latest version 1.33.0 (checked 2026-11-01)
Install: `npm install lightningcss`
License: MPL-2.0 (weak-copyleft)

In your own product (generator, app, hosted service): **conditions**. Weak copyleft: fine inside a closed product, but changes to the library's own files stay under its license and must be shared.

## Numbers (AgentGid data)
- Gid Score: 67.5 (#517 of all tools, 6 of 53 in its category)
- Used in 20 public projects set up for AI coding agents (0.3%)
- Downloads last week: 260,847,791 (as of 2026-11-24), +38.4% over 4 weeks
- GitHub stars: 7,732 (as of 2026-11-24)
- Last push: 2026-11-24

## Often used with
ESLint 75.0%, tw-animate-css 35.0%, react-markdown 30.0%, Playwright (JavaScript) 45.0%, TypeScript 80.0%, Tailwind CSS 60.0%

## Checked alternatives (same job)
- Sass: https://agentgid.com/tools/sass/agent.md
- sass-embedded: https://agentgid.com/tools/sass-embedded/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/lightningcss/
- Homepage: https://github.com/parcel-bundler/lightningcss#readme
- Repository: https://github.com/parcel-bundler/lightningcss


## Lightning CSS: shrink CSS and make it work in older browsers

Lightning CSS is a free build tool that reads your site's CSS and writes a smaller, safer copy. You can write new CSS features such as nesting or modern colors, name the oldest browsers you support, and it rewrites what they would not understand. It also adds browser prefixes, joins several CSS files into one and minifies the result.

### Where to use it
- Smaller CSS for a faster site: Before you publish, squeeze the stylesheet so visitors download fewer bytes; colors, shorthands and repeated rules get shorter.
- New CSS that older browsers still show: Your AI assistant writes CSS with nesting and oklch() colors; Lightning CSS rewrites it for the oldest Safari or Chrome your visitors use.
- Faster CSS step in a Vite project: Let Vite use Lightning CSS for processing and minifying the CSS of your React or Vue site.
- One file from many imports: Your styles are split into parts that import each other; ship them as one file so the page makes fewer requests.
- Class names that never clash: Two parts of the site both use a class called .title; scoped names keep their styles from overwriting each other.
- Replace a chain of CSS plugins: An older project runs several PostCSS plugins for prefixes and new syntax; one Lightning CSS step can take their place. (idea, not from the official pages)

### How to start
- Install it in your project as a build-time package.

```
npm install --save-dev lightningcss
```

- Call transform with the file name and the CSS as a Buffer.

```
import { transform } from 'lightningcss';

let { code, map } = transform({
  filename: 'style.css',
  code: Buffer.from('.foo { color: red }'),
  minify: true,
  sourceMap: true
});
```

- Pass browser targets, or nothing is rewritten for older browsers.

### License
Free to use, also in paid products, under the MPL-2.0 license. Running it on your CSS puts no license on the output. If you change Lightning CSS's own files and ship them, you share those changes.

### Good to know
- Without browser targets it only cleans up and minifies; nothing is rewritten for older browsers.
- It is strict by default and stops at broken rules; a recovery switch skips them with a warning instead.
- The browser build cannot join imported files or run custom plugins.
- Plugins such as Tailwind may still need PostCSS next to it.
- The project is active; version 1.33.0 came out on 20 July 2026 and it is the default CSS step in the Parcel build tool.

Checked 2026-11-11 against: https://github.com/parcel-bundler/lightningcss/blob/master/README.md, https://github.com/parcel-bundler/lightningcss/blob/master/LICENSE, https://registry.npmjs.org/lightningcss/1.33.0, https://registry.npmjs.org/lightningcss-cli-darwin-arm64/latest, https://lightningcss.dev/, https://lightningcss.dev/docs.html, https://lightningcss.dev/transpilation.html, https://lightningcss.dev/minification.html, https://lightningcss.dev/bundling.html, https://lightningcss.dev/css-modules.html

### Mistakes to avoid
- Don't: transform({ filename, code, minify: true }) and expecting nesting or oklch() to be rewritten → Do: Add targets, e.g. targets = browserslistToTargets(browserslist('>= 0.25%')), or --targets on the command line (Without targets nothing is lowered; in our run the output without --targets still had & nesting and oklch().)
- Don't: targets: { safari: 13 } or targets: ['safari 13'] → Do: Use browserslistToTargets(...), or encode versions like { safari: (13 << 16) | (2 << 8) } (The targets object stores each browser version as one packed number, not a plain version.)
- Don't: code: '.foo { color: red }' (a plain string) in transform() → Do: code: Buffer.from(css) in Node, or new TextEncoder().encode(css) with lightningcss-wasm (transform reads bytes, not strings.)
- Don't: Calling bundle() from lightningcss-wasm in the browser → Do: Use transform() in the browser and run bundling in Node or the command line (The WebAssembly build has no bundle or visitor functions.)
- Don't: Checking the installed version with lightningcss --version → Do: Check the version in package.json or package-lock.json (In our run the 1.33.0 binary printed "lightningcss 1.0.0-alpha.72", an old internal number.)

### Questions
- Can it run in the browser? Yes, through the lightningcss-wasm package, but without the bundle and plugin features.
- Does Vite support it? Yes. Set it as the CSS transformer and minifier in the Vite config.
- How do I say which browsers to support? Give a browserslist query to --targets on the command line, or use browserslistToTargets in code.
- Is there a command-line version? Yes, the lightningcss-cli package compiles, minifies and bundles CSS files without other build tools.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
