Hex to Tailwind colour

Paste any colour to find the nearest class in Tailwind’s default palette, for v4 or v3, and see how close it really is. Paste a Tailwind class to see the colour behind it.

  • Colour
  • Runs in your browser. Nothing is uploaded

Nearest Tailwind colours

Left half is your colour, right half is Tailwind’s. ΔE is the difference in OKLab: under 1 looks the same, over 3 is easy to see.

Use the exact colour

Closest shade in each colour

Click one to copy its class.

Type a colour

How the matching works

Your colour and all of Tailwind’s colours are converted to OKLab, and the distance between them is measured there. OKLab is designed so that the same distance looks like the same amount of difference, whatever the hue. That gives better matches than comparing hex or RGB values, which treat a small change in a dark blue the same as a small change in a pale yellow, even though you’d see one far more easily.

ΔELabelWhat it means
under 0.3Exact matchThe same colour, give or take rounding
0.3 to 1Looks identicalSafe to swap in
1 to 3Very closeYou might notice side by side
3 to 6Noticeably differentFine for a mock-up, not for a brand colour
over 6Not closeUse the arbitrary value instead

Tailwind v4 and v3 palettes

Tailwind v4 defines every colour in OKLCH, for example --color-blue-500: oklch(62.3% 0.214 259.815). Many of the new colours are slightly outside sRGB, the range most screens have shown for years, so on a wide-gamut screen they look more vivid. Where that happens, the tool also shows the nearest sRGB hex. v4 also adds mauve, olive, mist and taupe neutrals.

Tailwind v3 uses hex values, so a v3 colour pasted in with v3 selected always matches exactly. Moving a project from v3 to v4? Paste the old hex with v4 selected to see which shade it lands on now.

Transparent colours

If your colour has alpha, like #3b82f680 or rgb(59 130 246 / 50%), it’s matched at full opacity and the class gets an opacity modifier: bg-blue-500/50. v4 accepts any whole percentage. v3’s default scale goes in steps of 5, so other values are written as /[0.37].

Using the class

<!-- the nearest palette colour -->
<button class="bg-sky-500 text-white">Save</button>

<!-- the exact colour, no config needed -->
<button class="bg-[#1d9bf0] text-white">Save</button>

/* v4: add it to your theme once, then use bg-brand */
@theme {
  --color-brand: #1d9bf0;
}

Need the colour in another format? The colour converter gives HSL, OKLCH and more, and the contrast checker tells you whether text on it is readable.

Questions people ask

How do I find the closest Tailwind colour to a hex code?
Paste the hex code above. Every colour in Tailwind’s default palette is compared with yours in OKLab, a colour space built so that equal distances look equally different, and the closest ones are listed with how far off each one is.
What does ΔE mean?
ΔE is the distance between two colours. Here it’s measured in OKLab and multiplied by 100. Under 1, almost nobody can tell the colours apart. Between 1 and 3 they’re very close side by side. Above about 6 the difference is obvious.
Why is #3b82f6 not an exact match for blue-500 any more?
Tailwind v4 redefined its palette in OKLCH, and many colours moved slightly, often to more vivid shades that only wide-gamut screens can show. #3b82f6 is v3’s blue-500 exactly; in v4 it’s still closest to blue-500, but not identical. Switch to v3 to match the old palette.
What if no Tailwind colour is close enough?
Use an arbitrary value like bg-[#1d9bf0], which works without any config. If you’ll use the colour often, add it to your theme: @theme { --color-brand: #1d9bf0; } in v4, or theme.extend.colors in v3, then write bg-brand.
Can I look up what a Tailwind class is?
Yes. Type a class such as text-slate-700, hover:bg-sky-500/50 or var(--color-blue-500) to see its exact value, its hex and RGB, and the shades next to it.
↑↓ move↵ openesc close