Skip to content

OKLCH to HEX converter

Paste an OKLCH, hex, RGB or HSL colour and copy it in every format Tailwind CSS 4 and shadcn/ui use. oklch(62.3% 0.214 259.815) (Tailwind's blue-500) is #2b7fff. Below the converter, paste a whole stylesheet to convert every colour in it at once.

Left: as typed (wide gamut). Right: the sRGB hex.

oklch(), hex, rgb() or hsl(). Nothing leaves your browser.

HEX
#2b7fff
OKLCH (Tailwind 4)
oklch(62.3% 0.214 259.815)
OKLCH (shadcn/ui)
oklch(0.623 0.214 259.815)
RGB
rgb(43 127 255)
HSL
hsl(216.3 100% 58.5%)
Tailwind @theme
--color-brand: oklch(62.3% 0.214 259.815);
Closest Tailwind
blue-500ΔE 0.0
Top 5
Make a 50–950 Tailwind palette from this colour →

Convert a whole stylesheet

Paste a shadcn/ui globals.css, a Tailwind @theme block or any list. Every colour is converted; the rest stays as it is.

10 colours converted
:root {
  --background: #ffffff;
  --foreground: #0a0a0a;
  --primary: #1447e6;
  --primary-foreground: #eff6ff;
  --muted: #f5f5f5;
  --muted-foreground: #737373;
  --border: #e5e5e5;
  --ring: #a1a1a1;
  --chart-1: #f54900;
  --destructive: #e7000b;
  --radius: 0.625rem;
}

Your colour on finished blocks

The same colour as a complete shadcn/ui preset: primary, rings, charts and a matching dark set, every text colour checked for contrast. Below are six free blocks drawn with it. Change the colour above and they follow.

Make it a shadcn presetBrowse all blocks

In the generator you set the grey, radius and fonts, then install it with npx shadcn add. Free.

Tailwind 4.3 colours: OKLCH and hex

The 500 shade of each colour family, as Tailwind defines it and as the sRGB hex a browser draws. Every shade is on the Tailwind colors page.

ColourOKLCHHEX
red-500oklch(63.7% 0.237 25.331)#fb2c36
orange-500oklch(70.5% 0.213 47.604)#ff6900
amber-500oklch(76.9% 0.188 70.08)#fd9a00
yellow-500oklch(79.5% 0.184 86.047)#efb100
lime-500oklch(76.8% 0.233 130.85)#7ccf00
green-500oklch(72.3% 0.219 149.579)#00c950
emerald-500oklch(69.6% 0.17 162.48)#00bc7d
teal-500oklch(70.4% 0.14 182.503)#00bba7
cyan-500oklch(71.5% 0.143 215.221)#00b8db
sky-500oklch(68.5% 0.169 237.323)#00a6f4
blue-500oklch(62.3% 0.214 259.815)#2b7fff
indigo-500oklch(58.5% 0.233 277.117)#615fff
violet-500oklch(60.6% 0.25 292.717)#8e51ff
purple-500oklch(62.7% 0.265 303.9)#ad46ff
fuchsia-500oklch(66.7% 0.295 322.15)#e12afb
pink-500oklch(65.6% 0.241 354.308)#f6339a
rose-500oklch(64.5% 0.246 16.439)#ff2056

Questions

How do I convert OKLCH to HEX?

Paste the oklch() value above and copy the hex. The converter turns OKLCH into OKLab, then into linear and gamma-encoded sRGB, and writes that as #rrggbb. For example oklch(62.3% 0.214 259.815), Tailwind 4's blue-500, is #2b7fff. Lightness can be written as a percentage (62.3%) or a number (0.623); both are read.

Why does the hex not convert back to the same OKLCH?

Many OKLCH colours, including most of Tailwind 4's vivid 400–600 shades, lie outside sRGB, the range a hex code can hold. The browser then shows the nearest colour it can, and so does this converter, the CSS Color 4 way: it lowers chroma at the same lightness and hue until the colour fits. That hex, turned back into OKLCH, is a little less vivid than the value you started from. The converter says so when it happens.

How do I convert HEX to OKLCH for Tailwind CSS 4?

Paste the hex code and copy the OKLCH line. Tailwind 4 writes lightness as a percentage, oklch(62.3% 0.214 259.815); shadcn/ui writes it as a number, oklch(0.623 0.214 259.815). Both lines are shown. Put the value in your @theme block as --color-brand: oklch(…) and Tailwind makes bg-brand, text-brand and the rest.

Can I convert a whole shadcn globals.css to hex?

Yes. Paste the stylesheet into the box under "Convert a whole stylesheet". Every oklch() value is replaced with its hex code and everything else stays as it is, so you can paste the result into Figma tokens, an email template or a tool that does not read OKLCH. Switch the direction to turn hex codes back into OKLCH.

Which Tailwind color is closest to my OKLCH or hex value?

The converter shows the nearest Tailwind 4 color, measured as ΔE in OKLab. For the five closest, in v4 or v3, use Hex to Tailwind.

Is it free?

Yes. No sign-up, and nothing leaves your browser.

UI Pro

The same palette, already designed into finished blocks

Every block, page template and website theme from €199, paid once, with every update and everything we add later. Not ready? The free blocks are open to everyone.

blocks
1401
page templates
55
website themes
29
The About page template from UI Pro, built from its blocks.

This card is a UI Pro block: Rooilijn (call-to-action-07).