Color Transformations
Complete reference for color space conversions
The transforms API provides bidirectional color space conversions. All functions are available via api.transforms.
RGB Conversions
RGB ↔ Hex
Convert between RGB and hexadecimal color formats.
rgbToHex(rgb: RGB): Hex
hexToRgb(hex: Hex): RGB
rgbaToHex(rgba: RGBA): Hex
Converts RGBA (with alpha) to 8-character hex.
hexToRgba(hex: Hex): RGBA
RGB ↔ HSL
HSL (Hue, Saturation, Lightness) is intuitive for color manipulation.
rgbToHsl(rgb: RGB): HSL
Returns:
h- Hue (0-360 degrees)s- Saturation (0-100%)l- Lightness (0-100%)
hslToRgb(hsl: HSL): RGB
rgbaToHsla(rgba: RGBA): HSLA
hslaToRgba(hsla: HSLA): RGBA
RGB ↔ HSV
HSV (Hue, Saturation, Value) is commonly used in color pickers.
rgbToHsv(rgb: RGB): HSV
Returns:
h- Hue (0-360 degrees)s- Saturation (0-100%)v- Value/Brightness (0-100%)
hsvToRgb(hsv: HSV): RGB
rgbaToHsva(rgba: RGBA): HSVA
hsvaToRgba(hsva: HSVA): RGBA
HSV ↔ HSL
Direct conversion between HSV and HSL.
hsvToHsl(hsv: HSV): HSL
hslToHsv(hsl: HSL): HSV
RGB ↔ CMYK
CMYK is used for print design.
rgbToCmyk(rgb: RGB): CMYK
Returns:
c- Cyan (0-100%)m- Magenta (0-100%)y- Yellow (0-100%)k- Black/Key (0-100%)
cmykToRgb(cmyk: CMYK): RGB
RGB ↔ Linear RGB
Linear RGB removes gamma correction for accurate color blending.
rgbToLinearRgb(rgb: RGB): LinearRGB
linearRgbToRgb(linear: LinearRGB): RGB
RGB ↔ XYZ
CIE XYZ is the foundation for many color spaces.
rgbToXyz(rgb: RGB): XYZ
Uses D65 illuminant and sRGB color space.
xyzToRgb(xyz: XYZ): RGB
RGB ↔ LAB
CIE LAB provides perceptually uniform color space.
rgbToLab(rgb: RGB): LAB
Returns:
l- Lightness (0-100)a- Green-Red axis (-128 to +127)b- Blue-Yellow axis (-128 to +127)
labToRgb(lab: LAB): RGB
RGB ↔ LCH
LCH is cylindrical LAB (Lightness, Chroma, Hue).
rgbToLch(rgb: RGB): LCH
Returns:
l- Lightness (0-100)c- Chroma (0-150+)h- Hue angle (0-360 degrees)
lchToRgb(lch: LCH): RGB
LAB ↔ LCH
Direct conversion between LAB and LCH.
labToLch(lab: LAB): LCH
lchToLab(lch: LCH): LAB
XYZ ↔ LAB
Direct conversion between XYZ and LAB.
xyzToLab(xyz: XYZ): LAB
labToXyz(lab: LAB): XYZ
RGB ↔ OKLAB
OKLAB is a modern perceptual color space with better uniformity than LAB.
rgbToOklab(rgb: RGB): OKLAB
Returns:
l- Lightness (0-1)a- Green-Red axisb- Blue-Yellow axis
oklabToRgb(oklab: OKLAB): RGB
RGB ↔ OKLCH
OKLCH is cylindrical OKLAB (better for color manipulation).
rgbToOklch(rgb: RGB): OKLCH
Returns:
l- Lightness (0-1)c- Chroma (0-0.4+)h- Hue angle (0-360 degrees)
oklchToRgb(oklch: OKLCH): RGB
OKLAB ↔ OKLCH
Direct conversion between OKLAB and OKLCH.
oklabToOklch(oklab: OKLAB): OKLCH
oklchToOklab(oklch: OKLCH): OKLAB
RGB ↔ LMS
LMS represents cone responses (Long, Medium, Short wavelengths).
rgbToLms(rgb: RGB): LMS
Used primarily for color vision deficiency simulation.