Skip to content

Hex to OKLCH Converter

Convert hex color codes to the modern CSS oklch() format used by Tailwind CSS v4 and CSS Color Level 4. Enter a hex code and copy the perceptually uniform OKLCH value. All conversions happen in your browser.

Synchronized color

#2B7FFF

Parsed as RGB; malformed or out-of-range channels are rejected, never silently clamped.

Integer or percentage RGB, modern or legacy CSS, Hex with optional alpha, HSL, HSV, OKLCH, LAB, LCH, CMYK, or a CSS name.

100%

Adjust channels

43
127
255

Share this exact input

?color=2B7FFF

One input, implementation-ready output

Color workspace

Hex

#RRGGBB

#2B7FFF

CSS RGB

Modern space syntax

rgb(43 127 255)

Legacy RGB

Comma syntax

rgb(43, 127, 255)

RGB %

Percentage channels

rgb(16.9% 49.8% 100%)

HSL

CSS hue, saturation, lightness

hsl(216 100% 58%)

HSV / HSB

Design-tool model

hsv(216, 83%, 100%)

OKLCH

Perceptual CSS color

oklch(61.87% 0.2067 259.23)

LAB

CSS Lab, D50

lab(53.83% 11.48 -72.05)

LCH

CSS LCH, D50

lch(53.83% 72.95 279.05)

CMYK

Unprofiled approximation

cmyk(83%, 50%, 0%, 0%)

How Hex Converts to OKLCH

The conversion goes through the OKLab perceptual color space (Björn Ottosson's reference math):

  1. Decode the hex code to RGB channels and undo the sRGB gamma curve to get linear RGB.
  2. Transform linear RGB to the LMS cone response space with a 3×3 matrix, then take cube roots.
  3. Transform to OKLab (L, a, b) with a second matrix.
  4. Convert the a/b pair to polar form: chroma C = √(a² + b²) and hue H = atan2(b, a).

Example: convert #2B7FFF to OKLCH

#2B7FFF → rgb(43, 127, 255)

Linear RGB → OKLab: L = 0.623, a = −0.038, b = −0.211

C = √(a² + b²) = 0.214

H = atan2(−0.211, −0.038) ≈ 259.8°

Result: oklch(62.3% 0.214 259.8) - Tailwind v4 blue-500

How to Use the Hex to OKLCH Converter

Enter any hex color code and the CSS-ready oklch() value appears instantly, along with RGB, HSL, and CMYK equivalents. Copy the OKLCH value straight into your stylesheet or Tailwind theme configuration.

Understanding OKLCH Values

An OKLCH value like oklch(62.3% 0.214 259.8) reads as: 62.3% perceived lightness, 0.214 chroma (color intensity), at hue angle 259.8° (blue). Because the space is perceptually uniform, you can build an entire tint-and-shade scale by only changing L - something that never works cleanly in HSL.

Common Use Cases

Migrating design tokens to Tailwind CSS v4, building color scales that stay perceptually even, using wide-gamut P3 colors in modern CSS, and future-proofing design systems as tooling standardizes on OKLCH.

Hex to OKLCH Conversion Table

Hex, RGB, and OKLCH values for the most commonly used colors. Click any hex code to load it into the converter above.

ColorNameHexRGBOKLCH
Black#000000rgb(0, 0, 0)oklch(0% 0 0)
White#FFFFFFrgb(255, 255, 255)oklch(100% 0 0)
Red#FF0000rgb(255, 0, 0)oklch(62.8% 0.2577 29.23)
Lime#00FF00rgb(0, 255, 0)oklch(86.64% 0.2948 142.5)
Blue#0000FFrgb(0, 0, 255)oklch(45.2% 0.3132 264.05)
Yellow#FFFF00rgb(255, 255, 0)oklch(96.8% 0.211 109.77)
Cyan#00FFFFrgb(0, 255, 255)oklch(90.54% 0.1546 194.77)
Magenta#FF00FFrgb(255, 0, 255)oklch(70.17% 0.3225 328.36)
Silver#C0C0C0rgb(192, 192, 192)oklch(80.78% 0 0)
Gray#808080rgb(128, 128, 128)oklch(59.99% 0 0)
Maroon#800000rgb(128, 0, 0)oklch(37.67% 0.1546 29.23)
Olive#808000rgb(128, 128, 0)oklch(58.07% 0.1266 109.77)
Green#008000rgb(0, 128, 0)oklch(51.98% 0.1769 142.5)
Purple#800080rgb(128, 0, 128)oklch(42.09% 0.1935 328.36)
Teal#008080rgb(0, 128, 128)oklch(54.31% 0.0927 194.77)
Navy#000080rgb(0, 0, 128)oklch(27.11% 0.1879 264.05)
Orange#FFA500rgb(255, 165, 0)oklch(79.27% 0.171 70.67)
Pink#FFC0CBrgb(255, 192, 203)oklch(86.77% 0.0735 7.09)
Gold#FFD700rgb(255, 215, 0)oklch(88.68% 0.1822 95.33)
Brown#A52A2Argb(165, 42, 42)oklch(48.06% 0.1597 25.56)
Coral#FF7F50rgb(255, 127, 80)oklch(73.51% 0.168 40.25)
Indigo#4B0082rgb(75, 0, 130)oklch(33.9% 0.1793 301.68)
Violet#EE82EErgb(238, 130, 238)oklch(76.19% 0.1861 327.21)
Salmon#FA8072rgb(250, 128, 114)oklch(73.5% 0.1515 28.06)

Need a value that is not listed? Browse the full color library — every hex code has a page with its RGB, HSL, CMYK and OKLCH values, contrast ratios, tints, shades and matching palette colors.

Frequently Asked Questions about Hex to OKLCH Converter

OKLCH is a modern color format built on the OKLab perceptual color space. L is lightness (0-100%), C is chroma (roughly 0 to 0.4 for sRGB colors), and H is hue in degrees. Unlike HSL, equal lightness values actually look equally light across hues, which makes palettes far more predictable.