npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tbela99/css-parser

v1.4.6

Published

CSS parser, minifier and validator for node and the browser

Readme

playground npm npm cov Doc NPM Downloads bundle size

css-parser

CSS parser, transformer, minifier and validator for node and the browser

Installation

From npm

$ npm install @tbela99/css-parser

from jsr

$ deno add @tbela99/css-parser

Features

  • Zero dependencies — lightweight and easy to integrate into any project.
  • Standards-based CSS validation powered by MDN data.
  • Full CSS Modules support for modern component-based workflows.
  • Fault-tolerant parsing that follows the CSS Syntax Module Level 3 specification.
  • High-performance minification with safe optimizations and no unsafe transforms.
  • Advanced color processing with support for modern color spaces and functions, including color(), lab(), lch(), oklab(), oklch(), color-mix(), light-dark(), system colors, and relative colors.
  • Color conversion engine capable of transforming colors between all supported formats.
  • Automatic CSS nesting generation from compatible selectors.
  • Source map generation for easier debugging and development workflows.
  • Shorthand property computation to reduce output size and improve optimization.
  • Transform function optimization for more compact CSS output.
  • Math function evaluation, including calc(), clamp(), min(), max(), and related expressions.
  • CSS variable inlining where values can be safely resolved.
  • Duplicate declaration removal to eliminate redundant rules.
  • @import flattening to produce self-contained stylesheets.

Vendor prefix removal

Experimental vendor prefix cleanup to modernize generated CSS.

Syntax lowering

CSS-Parser can transform these modern CSS features into lower-level CSS syntax:

  • Nested CSS transpilation to legacy-compatible syntax.
  • if() function transpilation for broader browser compatibility.
  • color-mix() function conversion convert new color-mix() syntax to any of the supported colors.

Benchmark

Across all tested datasets, css-parser consistently produces the smallest output among the benchmarked tools, including Lightning CSS, cssnano, csso, clean-css, css-tree, and esbuild.

The benchmark evaluates minification effectiveness on a diverse set of real-world stylesheets, including Bootstrap 4, Bootstrap 5, Tailwind CSS, Animate.css, Foundation, Font Awesome, Normalize.css, and others.

A sample result:

| File | ligthningcss | CSS Parser | | ------------------------------ | ------------- | ------------- | | tailwind.css - 2380419 bytes | 1864728 bytes | 1633251 bytes | | bootstrap-4.css - 200078 bytes | 153616 bytes | 144700 bytes | | bootstrap-5.css - 205481 bytes | 159987 bytes | 151258 bytes |

On the complete benchmark suite, css-parser generated a total output size of 2,204,888 bytes, compared to 2,494,113 bytes for Lightning CSS and larger outputs for all other tested minifiers. While some tools prioritize raw execution speed, css-parser focuses on maximizing compression while preserving stylesheet semantics, resulting in consistently smaller production bundles.

Playground

Try it online

Documentation

AST

Comment

  • typ: number
  • val: string, the comment

Declaration

  • typ: number
  • nam: string, declaration name
  • val: array of tokens
  • state: EnumAstNodeStatus, validation state
  • errors: ErrorDescription[], validation errors

Rule

  • typ: number
  • sel: string, css selector
  • chi: array of children
  • state: EnumAstNodeStatus, validation state
  • errors: ErrorDescription[], validation errors

AtRule

  • typ: number
  • nam: string. AtRule name
  • val: rule prelude
  • state: EnumAstNodeStatus, validation state
  • errors: ErrorDescription[], validation errors

AtRuleStyleSheet

  • typ: number
  • chi: array of children

KeyFrameRule

  • typ: number
  • sel: string, css selector
  • chi: array of children
  • state: EnumAstNodeStatus, validation state
  • errors: ErrorDescription[], validation errors

Sourcemap

  • [x] Sourcemap generation

Computed shorthands properties

  • [ ] ~all~
  • [x] animation
  • [x] background
  • [x] border
  • [ ] border-block-end
  • [ ] border-block-start
  • [x] border-bottom
  • [x] border-color
  • [ ] border-image
  • [ ] border-inline-end
  • [ ] border-inline-start
  • [x] border-left
  • [x] border-radius
  • [x] border-right
  • [x] border-style
  • [x] border-top
  • [x] border-width
  • [x] column-rule
  • [x] columns
  • [x] container
  • [ ] contain-intrinsic-size
  • [x] flex
  • [x] flex-flow
  • [x] font
  • [ ] font-synthesis
  • [ ] font-variant
  • [x] gap
  • [ ] grid
  • [ ] grid-area
  • [ ] grid-column
  • [ ] grid-row
  • [ ] grid-template
  • [x] inset
  • [x] list-style
  • [x] margin
  • [ ] mask
  • [ ] offset
  • [x] outline
  • [x] overflow
  • [x] padding
  • [ ] place-content
  • [ ] place-items
  • [ ] place-self
  • [ ] scroll-margin
  • [ ] scroll-padding
  • [ ] scroll-timeline
  • [x] text-decoration
  • [x] text-emphasis
  • [x] transition

Performance

  • [x] Bundle file referenced by the @import statement.