RGB Converter

Convert colors between RGB, HEX, HSL, HSV, CMYK, XYZ, LAB, OKLAB, OKLCH and more – with live preview, copy buttons and contrast checker.

Supports HEX, RGB(A), HSL(A), HSV, HWB, CSS color names and more. Everything syncs automatically.

Enter color in any format

RGB

rgb(255, 102, 0)

HEX

#ff6600

HSL

hsl(24, 100%, 50%)

HSV

hsv(24, 100%, 100%)

CMYK (print)

cmyk(0%, 60%, 100%, 0%)

Advanced color spaces

XYZ (D65)

X=0.000, Y=0.000, Z=0.000

CIELAB (Lab)

L=0.0, a=0.0, b=0.0

OKLAB

L=0.0000, a=0.0000, b=0.0000

OKLCH

L=0.0000, C=0.0000, h=0.0°

WCAG contrast checker

Choose a text color to test against the current background.

Sample text
Contrast ratio:
WCAG 2.1:
  • Normal text (AA):
  • Normal text (AAA):
  • Large text (AA):
  • Large text (AAA):

How this RGB converter works

This tool uses a modern color engine to keep all representations of the same color in sync. You can start from any supported format (RGB, HEX, HSL, HSV, CMYK, CSS color string) and the converter will:

  • Parse your input and normalize it to sRGB (0–255 per channel).
  • Convert sRGB to linear RGB and then to CIE XYZ using the D65 reference white.
  • From XYZ, compute CIELAB, OKLAB and OKLCH using published matrices and transfer functions.
  • Update all fields, the live preview and the contrast checker in real time.

Key formulas (simplified)

1. sRGB to linear RGB

For each channel \(c \in \{R,G,B\}\) normalized to 0–1:
if c ≤ 0.04045:  c_lin = c / 12.92
else:            c_lin = ((c + 0.055) / 1.055) ^ 2.4
            

2. Linear RGB to XYZ (D65)

Using the standard sRGB matrix:
X = 0.4124564 R_lin + 0.3575761 G_lin + 0.1804375 B_lin
Y = 0.2126729 R_lin + 0.7151522 G_lin + 0.0721750 B_lin
Z = 0.0193339 R_lin + 0.1191920 G_lin + 0.9503041 B_lin
            

3. XYZ to CIELAB

With reference white \(X_n, Y_n, Z_n\) (D65):
f(t) = t > (6/29)^3 ? t^(1/3) : (1/3)(29/6)^2 t + 4/29

L* = 116 f(Y / Y_n) - 16
a* = 500 [f(X / X_n) - f(Y / Y_n)]
b* = 200 [f(Y / Y_n) - f(Z / Z_n)]
            

4. OKLAB and OKLCH

OKLAB is a perceptual color space proposed by Björn Ottosson. It is computed via a linear transform from linear RGB to LMS, a non‑linear compression, and another linear transform to L, a, b. OKLCH is the polar form:

C = sqrt(a² + b²)
h = atan2(b, a) (in degrees)
            

WCAG contrast ratio

The contrast checker uses the WCAG 2.1 relative luminance formula. For each color, we compute linear RGB, then:

L = 0.2126 R_lin + 0.7152 G_lin + 0.0722 B_lin

Contrast ratio = (L1 + 0.05) / (L2 + 0.05)
where L1 ≥ L2
            

AA for normal text requires a contrast ratio of at least 4.5:1, while AAA requires 7:1. For large text (≥ 18 pt regular or 14 pt bold), AA requires 3:1 and AAA requires 4.5:1.

FAQ

Can I convert RGB to Pantone?

This converter does not include proprietary Pantone libraries. To approximate a Pantone color, convert your RGB to LAB or OKLCH here and then use a Pantone‑matching tool that supports LAB input, or consult a physical swatch book for print‑critical work.

Why do CMYK values differ between tools?

CMYK depends on the print profile (ink set, paper, press). This tool uses a simple device‑independent approximation from RGB. Professional prepress workflows use ICC profiles, which can yield different CMYK values for the same RGB color.

Is this converter suitable for web accessibility work?

Yes. The RGB/HEX outputs are standard sRGB, and the built‑in WCAG contrast checker helps you verify that your text/background combinations meet AA or AAA requirements for both normal and large text.