{"id":15423,"library":"color-stringify","title":"Color Stringifier","description":"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`.","status":"abandoned","version":"1.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/dfcreative/color-stringify","tags":["javascript","color","stringify","color-string"],"install":[{"cmd":"npm install color-stringify","lang":"bash","label":"npm"},{"cmd":"yarn add color-stringify","lang":"bash","label":"yarn"},{"cmd":"pnpm add color-stringify","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides a list of CSS color keywords for 'keyword' output type.","package":"color-name","optional":false}],"imports":[{"note":"This package is CommonJS-only and does not provide an ES module export. Use `require()`.","wrong":"import stringify from 'color-stringify';","symbol":"stringify","correct":"const stringify = require('color-stringify');"},{"note":"While `require('color-stringify')` returns the function directly, destructuring can also be used if the module's default export is `module.exports = stringify`.","wrong":"import { stringify } from 'color-stringify';","symbol":"stringify","correct":"const { stringify } = require('color-stringify');"}],"quickstart":{"code":"const stringify = require('color-stringify');\n\n// Example 1: HSL array to HSLA string\nconst hslaString = stringify([120, 100, 100, 0.4], 'hsl');\nconsole.log(`HSL array to HSLA: ${hslaString}`);\n// Expected: hsla(120, 100%, 100%, .4)\n\n// Example 2: RGB array to default RGBA string\nconst rgbaString = stringify([255, 0, 128, 0.75]);\nconsole.log(`RGB array to RGBA: ${rgbaString}`);\n// Expected: rgba(255, 0, 128, 0.75)\n\n// Example 3: RGB object (from color-parse) to HEX string\nconst colorObject = { r: 51, g: 153, b: 255, alpha: 1, type: 'rgb' };\nconst hexString = stringify(colorObject, 'hex');\nconsole.log(`RGB object to HEX: ${hexString}`);\n// Expected: #3399FF\n\n// Example 4: RGB array to keyword (if available)\nconst keywordString = stringify([255, 0, 0], 'keyword');\nconsole.log(`RGB array to keyword: ${keywordString}`);\n// Expected: red","lang":"javascript","description":"Demonstrates stringifying various color formats (arrays, objects) into different CSS string types using the `stringify` function."},"warnings":[{"fix":"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.","message":"This package is CommonJS-only and does not provide native ES module exports. Direct `import` statements will fail in pure ESM environments or modern Node.js versions without specific configurations (e.g., `--experimental-json-modules` or transpilation).","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"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.","message":"The package has not been updated since February 2019 (version 1.2.1). This indicates it is no longer actively maintained and may not be compatible with newer JavaScript features, environments, or security standards. There are no TypeScript definitions shipped with the package.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"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`.","message":"When using `type: 'keyword'`, the input color must exactly match a known CSS color name's RGB value. If no exact match is found, it will fall back to a default `rgba()` representation, which might be unexpected.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"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');`.","cause":"`color-stringify` is a CommonJS module being imported into an ES module context without proper interoperability.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... From `color-stringify`"},{"fix":"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.","cause":"Incorrect import of the `stringify` function. If you used `import { stringify } from 'color-stringify';` in a CJS context, or if `require('color-stringify')` returned an object instead of the function itself.","error":"TypeError: stringify is not a function"}],"ecosystem":"npm"}