color-stringify is a JavaScript utility for converting various color value representations (like arrays of RGB/HSL components or objects) into standard CSS color strings. It supports outputting in formats such as hex (`#RRGGBB`), keywords (`red`), percentage (`rgb(10%, 20%, 30%)`), and several Adobe-specific formats, alongside the default `rgba()` or `hsla()` output. The library is currently at version 1.2.1, with its last update in early 2019, suggesting an abandoned or maintenance-only release cadence. It differentiates itself by offering a specific utility for stringifying pre-parsed color values, often paired with a parsing library like `color-parse`.
npm install color-stringifyVerified import paths — ran on the pinned version, not inferred.
Demonstrates stringifying various color formats (arrays, objects) into different CSS string types using the `stringify` function.
Use `const stringify = require('color-stringify');` instead of `import` statements. For ESM projects, consider using a compatibility layer or a modern alternative that supports ESM.Review the source code for potential vulnerabilities or compatibility issues before integrating into critical applications. Consider migrating to a more actively maintained color utility library for modern projects, especially those requiring ESM or TypeScript support.
Ensure the input color corresponds to a standard CSS color keyword for reliable keyword output. Otherwise, use `undefined` or another specific type like `hex` or `rgb`.
If in a modern Node.js ESM module (e.g., `"type": "module"` in `package.json`), you cannot directly `require()` a CJS module in all cases. Try `import * as stringify from 'color-stringify';` or consider a CJS-compatible wrapper, but the most reliable fix is often to use `require()` in a CJS context or migrate to an ESM-first alternative. For this specific package, revert to CJS usage if possible: `const stringify = require('color-stringify');`.Ensure you are using `const stringify = require('color-stringify');` as the package exports the function directly as `module.exports`. If you are in an ESM context trying to import, see the `ERR_REQUIRE_ESM` warning.