css-value

raw JSON →
0.0.1 verified Sat Apr 25 auth: no javascript abandoned

A work-in-progress CSS value parser by TJ Holowaychuk. Version 0.0.1, no recent updates. It is a minimal parser that extracts CSS property values from strings. This package is a very early experimental release with no stability guarantees, no documentation, and no test coverage. Not recommended for production use; alternatives like postcss-value-parser or csstree are more mature.

error Cannot find module 'css-value'
cause Package not installed or not in node_modules.
fix
npm install css-value
error TypeError: parse is not a function
cause Incorrect import (default vs named).
fix
Use import parse from 'css-value' or const parse = require('css-value').
breaking Package is experimental and may not parse correctly.
fix Use a stable parser like postcss-value-parser.
deprecated No updates since 2012; consider it unmaintained.
fix Migrate to an actively maintained package.
npm install css-value
yarn add css-value
pnpm add css-value

Parses a CSS value string into an object with property and value fields.

import parse from 'css-value';

const css = 'color: red; font-size: 14px; background-color: #fff;';
const values = css.split(';').map(part => parse(part.trim()));
console.log(values);
// [{property: 'color', value: 'red'}, ...] (approximate)