
Security News
VulnCon 2025: NVD Scraps Industry Consortium Plan, Raising Questions About Reform
At VulnCon 2025, NIST scrapped its NVD consortium plans, admitted it can't keep up with CVEs, and outlined automation efforts amid a mounting backlog.
css-color-converter
Advanced tools
Converts CSS colors from one representation to another
npm install css-color-converter
Example usage:
import { fromString } from 'css-color-converter';
fromString('rgb(255, 255, 255)').toHslString(); // hsl(0, 0%, 100%)
fromString('rgba(255, 255, 255, 0.5)').toHslString(); // hsla(0, 0%, 100%, 0.5)
fromString('blue').toRgbString(); // rgb(0, 0, 255)
fromString('red').toHexString(); // #ff0000
fromString(str)
parameter | type | description |
---|---|---|
str | string | Supports named colors, hex, rgb/rgba, hsl/hsla |
Returns instance
if valid, null
if invalid.
fromRgb([r, g, b])
parameter | type | description |
---|---|---|
r | int | red (0-255) |
g | int | green (0-255) |
b | int | blue (0-255) |
Returns instance
fromRgba([r, g, b, a])
parameter | type | description |
---|---|---|
r | int | red (0-255) |
g | int | green (0-255) |
b | int | blue (0-255) |
a | float | alpha (0-1) |
Returns instance
fromHsl([h, s, l])
parameter | type | description |
---|---|---|
h | int | hue (0-360) |
s | int | saturation (0-100) |
l | int | luminosity (0-100) |
Returns instance
fromHsla([h, s, l, a])
parameter | type | description |
---|---|---|
h | int | hue (0-360) |
s | int | saturation (0-100) |
l | int | luminosity (0-100) |
a | float | alpha (0-1) |
Returns instance
toRgbString()
Returns rgb()
or rgba()
, depending on the alpha.
toHslString()
Returns hsl()
or hsla()
, depending on the alpha.
toHexString()
Returns 6-digit or 8-digit hex
, depending on the alpha.
toRgbaArray()
Returns [r, g, b, a]
array.
FAQs
Converts CSS colors from one representation to another
The npm package css-color-converter receives a total of 22,947 weekly downloads. As such, css-color-converter popularity was classified as popular.
We found that css-color-converter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At VulnCon 2025, NIST scrapped its NVD consortium plans, admitted it can't keep up with CVEs, and outlined automation efforts amid a mounting backlog.
Product
We redesigned our GitHub PR comments to deliver clear, actionable security insights without adding noise to your workflow.
Product
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.