User Rating 0.0
Total Usage 0 times
Category CSS Tools
Accepts HEX, RGB(A), HSL(A), or CSS named colors
Is this tool helpful?

Your feedback helps us improve.

About

Color space conversion is non-trivial. A naive HEX-to-RGB parser ignores gamma correction entirely. Converting to perceptual spaces like CIE LAB requires linearizing sRGB values, transforming through the CIE XYZ intermediate space with the D65 illuminant matrix, then applying a cube-root companding function. Get any step wrong and your L* lightness value drifts by 5 - 15 units, enough to break accessibility contrast checks. CMYK conversion without a device ICC profile is inherently an approximation; this tool uses the standard formulaic approach where K = 1 max(R′, G′, B′). It will not match a Pantone swatch book.

This converter parses any valid CSS color string, including all 148 named colors, and outputs precise values across 8 color spaces simultaneously. It calculates WCAG 2.1 relative luminance and contrast ratios against white and black backgrounds so you can verify AA and AAA compliance on the spot. Palette harmonies (complementary, analogous, triadic, split-complementary) are computed via hue rotation in HSL space. Note: LAB and LCH values assume the sRGB gamut and D65 standard illuminant. Colors outside sRGB gamut cannot be represented.

color converter hex to rgb rgb to hsl color picker css colors color space cmyk converter lab color color palette

Formulas

The sRGB-to-CIE-LAB pipeline proceeds through three transformations. First, each sRGB channel is linearized by removing gamma companding:

{
Clin = CsRGB12.92 if CsRGB 0.04045Clin = pow(CsRGB + 0.0551.055, 2.4) otherwise

where CsRGB is each channel (R, G, or B) normalized to [0, 1]. Next, linear RGB is transformed to CIE XYZ (D65 illuminant) via the standard 3×3 matrix:

X=YZ 0.41245640.35757610.18043750.21267290.71515220.07217500.01933390.11919200.9503041 RlinGlinBlin

Finally, XYZ is converted to LAB using the D65 reference white (Xn = 0.95047, Yn = 1.00000, Zn = 1.08883):

L* = 116 f(Y ÷ Yn) 16
a* = 500 (f(X ÷ Xn) f(Y ÷ Yn))
b* = 200 (f(Y ÷ Yn) f(Z ÷ Zn))

where the transfer function f(t) applies a cube root for values above the threshold δ = 6÷29:

{
f(t) = t1/3 if t > δ3f(t) = t3δ2 + 429 otherwise

LCH is the polar form of LAB: C* = a*2 + b*2 and h = atan2(b*, a*). HSL conversion uses the standard min/max channel decomposition. CMYK is computed as K = 1 max(R′, G′, B′), with C = (1 R′ K) ÷ (1 K) and analogously for M and Y. WCAG relative luminance: L = 0.2126Rlin + 0.7152Glin + 0.0722Blin.

Reference Data

Color SpaceChannelsRangesGamutPerceptual UniformityCommon Use
sRGBR, G, B0 - 255 (integer)sRGBNoWeb, screens, CSS
HEXR, G, B (base-16)00 - FFsRGBNoCSS shorthand
HSLH, S, L0 - 360°, 0 - 100%, 0 - 100%sRGBNoCSS, design tools
HSV/HSBH, S, V0 - 360°, 0 - 100%, 0 - 100%sRGBNoPhotoshop, color pickers
CMYKC, M, Y, K0 - 100%Device-dependentNoPrint production
HWBH, W, B0 - 360°, 0 - 100%, 0 - 100%sRGBNoCSS Level 4
CIE LABL*, a*, b*0 - 100, ≈−128 - 127Unbounded (human vision)Yes (approximately)Color science, ΔE comparison
CIE LCHL*, C*, h0 - 100, 0 - 150+, 0 - 360°UnboundedYesPerceptual palettes
CSS Namedkeyword148 namessRGBN/AQuick CSS authoring
RGBAR, G, B, α0 - 255, 0 - 1sRGBNoTransparent overlays
HSLAH, S, L, αsame as HSL + 0 - 1sRGBNoCSS transparency
Linear RGBR, G, B0 - 1 (float)sRGB (linear)NoIntermediate for XYZ
CIE XYZX, Y, Z0 - 1 (approx)UnboundedNoColor science pipeline

Frequently Asked Questions

This tool computes CMYK using a formulaic RGB-to-CMYK conversion without an ICC color profile. Real-world print workflows use device-specific ICC profiles (e.g., FOGRA39 for European coated paper) that account for ink behavior, dot gain, and paper whiteness. The values here are a reasonable approximation for screen design reference but should not be used as final production specifications. Always request a proof from your printer.
The conversion uses the CIE D65 standard illuminant (daylight, correlated color temperature of 6504 K) with the CIE 1931 2° standard observer. The reference white tristimulus values are X_n = 0.95047, Y_n = 1.00000, Z_n = 1.08883. If you need D50 (common in print/ICC workflows), you must apply a chromatic adaptation transform (Bradford) to the XYZ values before converting to LAB.
WCAG 2.1 contrast ratio is (L1 + 0.05) / (L2 + 0.05) where L1 is the relative luminance of the lighter color and L2 of the darker. Relative luminance derives from linearized sRGB channels weighted by human spectral sensitivity (0.2126R + 0.7152G + 0.0722B). AA compliance requires a ratio of at least 4.5:1 for normal text and 3:1 for large text (18pt+ or 14pt+ bold). AAA requires 7:1 and 4.5:1 respectively.
HSL and HSV define saturation differently. HSV saturation measures the distance from white (how "pure" the hue is relative to maximum brightness), computed as (max − min) / max. HSL saturation measures the distance from gray on the same lightness level, computed as (max − min) / (1 − |2L − 1|). A color with HSV saturation 100% and value 50% will have HSL saturation 100% but lightness 25%. They are geometrically different cylindrical mappings of the same RGB cube.
No. The input is limited to sRGB-representable colors (8-bit per channel, 0-255). CIE LAB and LCH can theoretically describe colors beyond sRGB, but since the input is sRGB, the output LAB/LCH values will always fall within the sRGB gamut boundary. Display P3 or Rec.2020 colors are not supported. If you input LAB values that exceed sRGB gamut when reverse-converting, channels will be clamped to 0-255.
Alpha is preserved as-is across all conversions. It is a separate channel that does not participate in color space math. When converting RGBA to CMYK, the alpha is simply carried along but CMYK itself has no native alpha concept. For HEX output, an 8-digit hex string is produced (e.g., #FF000080 for 50% transparent red). The preview swatch renders alpha over a checkerboard pattern to visualize transparency.