css-tree
npmv3.2.1A tool set for CSS: fast detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations
Safe to adopt
Yes — css-tree scores well across adoption, maintenance, weight, supply chain, and licensing. No download data reported for this package yet. Last published 188 days ago. 5 releases in the last 2 years.
- ?Adoption: grade ?, Not reported by this registry.
No download data reported for this package yet.
- BMaintenance: grade B, Good.
Last published 188 days ago. 5 releases in the last 2 years.
- AWeight: grade A, Excellent.
Pulls in 2 transitive packages, about 2.1 MB installed.
- ASupply chain: grade A, Excellent.
No install scripts, 2 maintainers, and a contained dependency surface.
- ALicense: grade A, Excellent.
MIT — permissive, with no copyleft found in the dependency tree.
Grades are computed deterministically from registry metadata collected by PackageGraph — downloads, dependents, publish dates, the resolved dependency tree, maintainer count, and declared licenses. No third-party scores are used.
Install cost
What you actually take on by adding css-tree to a project.
Runtime packages this one declares itself.
Distinct packages in the full runtime tree, deduplicated the way a package manager would.
Unpacked size of this package plus its entire runtime tree.
Longest resolved dependency chain below this package.
Licenses in the dependency tree
Every license you inherit by installing css-tree, not just its own. Check this before a legal review, not after.
Compatibility
- Node.js
- node ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0
- Module format
- ESM + CommonJS
- TypeScript
- No bundled types
- Install scripts
- None
Quick start
A usage example from the css-tree README.
import * as csstree from 'css-tree';
// parse CSS to AST
const ast = csstree.parse('.example { world: "!" }');
// traverse AST and modify it
csstree.walk(ast, (node) => {
if (node.type === 'ClassSelector' && node.name === 'example') {
node.name = 'hello';
}
});
// generate CSS from AST
console.log(csstree.generate(ast));css-tree vs the alternatives
Packages solving a similar problem in the npm ecosystem, compared on the signals that drive an adoption decision.
| Package | Weekly downloads | Dependents | License | Last release |
|---|---|---|---|---|
| css-treethis page | 0 | 5 | MIT | 6 months ago |
| esprima | 77.6M | 5 | BSD-2-Clause | 1 day ago |
| sugarss | 0 | 1 | MIT | 1 day ago |
| @adobe/css-tools | 0 | 2 | MIT | 1 day ago |
| espree | 0 | 4 | BSD-2-Clause | 1 day ago |
| postcss | 249.3M | 7 | MIT | 1 day ago |
Dependencies
Declared by css-tree v3.2.1. Runtime dependencies are installed with the package; dev dependencies are not.
Runtime (2)
Dev (7)
Used by
Popular packages that depend on css-tree.
Strict TypeScript and Flow types for style based on MDN data
A JavaScript implementation of many web standards
Calculate specificity of a CSS Selector
CSS syntax patches for CSS tree
A CSS selector engine.
Relationship graph
Dependencies (left) and dependents (right) of css-tree.
Frequently installed together
An AST-based pattern checker for JavaScript.
Check whether a given string matches the `PotentialCustomElementName` production as defined in the HTML Standard.
🔎 A simple, tiny and lightweight benchmarking library!
Prettier is an opinionated code formatter
TypeScript definitions for node
A JavaScript implementation of many web standards
the complete solution for node.js command-line programs
A JavaScript implementation of the Unicode Bidirectional Algorithm
BDD/TDD assertion library for node.js and the browser. Test framework agnostic.
The semantic version parser used by npm.
An implementation of the WHATWG URL Standard's URL API and parsing machinery
An HTTP/1.1 client, written from scratch for Node.js
Release history
3 releases in the last two years, typically about 14 days apart.
| Version | Published | Size | License |
|---|---|---|---|
| 3.2.1latest | 6 months ago | 1.3 MB | MIT |
| 3.2.0 | 6 months ago | 1.3 MB | MIT |
| 3.1.0 | 1 year ago | 1.3 MB | MIT |
| 3.0.1 | 1 year ago | 1.3 MB | MIT |
| 3.0.0 | 2 years ago | 1.3 MB | MIT |
| 2.3.1 | 3 years ago | 1.1 MB | MIT |
| 2.3.0 | 3 years ago | 1.1 MB | MIT |
| 2.2.1 | 4 years ago | 1.1 MB | MIT |
| 2.2.0 | 4 years ago | 1.1 MB | MIT |
| 2.1.0 | 4 years ago | 1.1 MB | MIT |
| 2.0.4 | 4 years ago | 1.1 MB | MIT |
| 2.0.3 | 4 years ago | 1.1 MB | MIT |
| 2.0.2 | 4 years ago | 1.1 MB | MIT |
| 2.0.1 | 4 years ago | 1.0 MB | MIT |
| 2.0.0 | 4 years ago | 1.0 MB | MIT |
Overview
css-tree is an npm package that a tool set for CSS: fast detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations. It has 5 known dependents in the graph. The latest version is 3.2.1, released under the MIT license.
Who should use it
Teams working in the npm ecosystem who need a tool set for CSS: fast detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations and value a focused solution.
When not to use it
Consider an alternative if you need to have first-class TypeScript types out of the box, or if a more actively-maintained option better fits your npm stack.
Pros
- Clear open-source license (MIT).
Cons
- No bundled TypeScript types (may require a separate @types package).
Auto-generated from collected registry metadata. No external claims are inferred.
Frequently asked questions
Should I use css-tree?
Yes — css-tree scores well across adoption, maintenance, weight, supply chain, and licensing. No download data reported for this package yet. Last published 188 days ago. 5 releases in the last 2 years.
How do I install css-tree?
Run `npm install css-tree` to add css-tree to your npm project.
How many dependencies does css-tree have?
css-tree declares 9 direct dependencies and pulls in 2 packages in total once its runtime tree is resolved totalling about 2.1 MB on disk.
What license is css-tree released under?
css-tree is distributed under the MIT license. Its dependency tree also includes: BSD-3-Clause, CC0-1.0.
How popular is css-tree?
npm does not publish download counts. Within PackageGraph's crawl, 5 known packages depend on css-tree.
Is css-tree still maintained?
The most recent release of css-tree (v3.2.1) was published 6 months ago.
Does css-tree run install scripts?
No. css-tree does not define preinstall, install, or postinstall scripts, so installing it does not execute publisher-supplied code.