postcss-values-parser
A CSS property value parser that uses css-tree for parsing,
and models nodes on top of PostCSS’s Node/Container/Root classes so the API feels familiar to PostCSS users.
This package powers part of Prettier . Please consider becoming a sponsor if you find this package useful or are a Prettier user. https://github.com/sponsors/shellscape
Install
Using npm:
npm install postcss-values-parser --save-dev copy
Requirements
Node.js >= 20.19.0
PostCSS >= 8.4.14 (peer dependency)
Note: This package is ESM‑only. Use import in Node.js. In CommonJS on Node >= 20.19.0, require() can load ES modules:
// CommonJS (Node >= 20.19.0)
const { parse } = require ( 'postcss-values-parser' ); copy
Benefits
Uses css-tree for fast, standards‑compliant parsing
Builds PostCSS‑style nodes for a familiar API
Doesn't strip characters; e.g., parentheses are preserved in the AST
Full AST traversal
Optional walker helpers (registerWalkers(Container)) to walk by node type
Convenience methods to stringify nodes
Provides convenience properties for number units, colors, etc.
Usage
Please see the Documentation for general use and further information on using the package.
CONTRIBUTING
LICENSE (Mozilla Public License)