
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
normalize-colors
Advanced tools
Normalize any CSS color value to a hex string (#RRGGBB). Supports hex, named colors, and all major CSS color functions and spaces.
npm install normalize-colors
# or
npm i normalize-colors
const normalizeColor = require("normalize-colors");
// or
import normalizeColor from "normalize-colors";
normalizeColor("red"); // "#FF0000"
normalizeColor("rgb(255, 0, 0)"); // "#FF0000"
normalizeColor("hsl(0 100% 50%)"); // "#FF0000"
normalizeColor("color(display-p3 1 0 0)"); // "#FF0000"
Returns #RRGGBB for valid colors, or #000000 for invalid/missing input. Alpha is ignored; output is always opaque hex.
| Format | Example |
|---|---|
| 6-digit hex | #FF0000, #ff0000 |
| 3-digit hex | #F00 → #FF0000 |
All CSS named colors (e.g. red, aliceblue, rebeccapurple) and transparent (normalized to 0x00000000).
| Syntax | Example |
|---|---|
rgb(r g b) | rgb(255 0 0) |
rgb(r, g, b) | rgb(255, 0, 0) |
rgba(r, g, b, a) | rgba(255, 0, 0, 0.5) |
Values: 0–255 for r,g,b; alpha is ignored for output.
| Syntax | Example |
|---|---|
hsl(h s% l%) | hsl(120 100% 50%) |
hsl(h, s%, l%) | hsl(120, 100%, 50%) |
hsla(h, s%, l%, a) | hsla(120, 100%, 50%, 0.5) |
| Syntax | Example |
|---|---|
hwb(h w% b%) | hwb(120 50% 0%) |
hwb(h, w%, b%) | hwb(120, 50%, 0%) |
| Syntax | Example |
|---|---|
lab(L a b) | lab(50 10 -5) |
lab(L% a b) | lab(50% 0 0) |
| Syntax | Example |
|---|---|
lch(L C H) | lch(50% 20 180) |
lch(L, C, H) | lch(50, 20, 180) |
| Syntax | Example |
|---|---|
oklab(L a b) | oklab(0.6 0.1 -0.05) |
oklab(L% a b) | oklab(60% 0.1 -0.05) |
| Syntax | Example |
|---|---|
oklch(L C H) | oklch(0.6 0.2 180) |
oklch(L%, C, H) | oklch(60% 0.2 180) |
color() functionAll spaces defined in CSS Color Module Level 4 for color() are supported. Components are numbers in the range 0–1 or percentages; optional alpha after / is ignored.
| Space | Description | Example |
|---|---|---|
srgb | sRGB (gamma-encoded) | color(srgb 0.5 0 0) |
srgb-linear | Linear sRGB | color(srgb-linear 0.215 0 0) |
display-p3 | Display P3 (D65) | color(display-p3 0.24 0.52 0.48) |
a98-rgb | Adobe RGB (1998) | color(a98-rgb 0.44 0.5 0.37) |
prophoto-rgb | ProPhoto RGB (D50) | color(prophoto-rgb 0.28 0.4 0.42) |
rec2020 | ITU-R BT.2020 | color(rec2020 0.42 0.48 0.36) |
xyz | CIE XYZ (D65) | color(xyz 0.2 0.15 0.6) |
xyz-d50 | CIE XYZ (D50) | color(xyz-d50 0.2 0.14 0.45) |
xyz-d65 | CIE XYZ (D65) | color(xyz-d65 0.22 0.15 0.59) |
Syntax: color(<space> <c1> <c2> <c3> [ / <alpha> ])
Components can be space- or comma-separated. Values can be numbers (0–1), percentages (0%–100%), or none (treated as 0).
transparent.rgb, rgba, hsl, hsla, hwb, lab, lch, oklab, oklch, and color(<space> ...) with all predefined RGB and XYZ spaces above.All of these are normalized to a single opaque hex string for consistent use in code or further processing.
FAQs
normalize colors
We found that normalize-colors demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.