Tailwind Color Converter: HEX to the Nearest Tailwind Class

Enter a 6-digit HEX color to find the five closest colors in the Tailwind CSS v3 default palette. Each match shows its class name, its v3 HEX value, its Tailwind v4 OKLCH value and a distance badge.

Nearest Tailwind colors:

blue-500Exact

#3B82F6

oklch(62.3% 0.214 259.815)

indigo-500Close

#6366F1

oklch(58.5% 0.233 277.117)

sky-600Close

#0284C7

oklch(58.8% 0.158 241.966)

indigo-400Close

#818CF8

oklch(67.3% 0.182 276.935)

blue-600Close

#2563EB

oklch(54.6% 0.245 262.881)

Related Developer Tools

Runs in your browser: your files and text are not uploaded. Free, no account needed.

Last updated: · Reviewed by the QuickTooly Team

How the matching works

Which Tailwind Palette Is Used

The tool holds the Tailwind CSS v3 default palette as HEX values: 22 color families from slate to rose, each with 11 steps from 50 to 950, plus black and white. That is 244 colors. The 950 steps arrived in Tailwind v3.3, so they are included.

Tailwind v4 redefined its default palette in OKLCH with slightly different values. The OKLCH string and the v4 copy button show the v4 value for the same class name, taken from the Tailwind v4 package. For example, blue-500 is #3b82f6 in v3 and oklch(62.3% 0.214 259.815) in v4. The nearest match is still found using the v3 HEX values.

How the Nearest Match Is Found

Your color and every palette color are converted to OKLAB (L, a, b). The distance is the straight-line distance ΔE = √(ΔL² + Δa² + Δb²). The five smallest distances are listed, closest first.

  • Exact: ΔE below 0.01.
  • Very close: ΔE from 0.01 to below 0.05.
  • Close: ΔE from 0.05 to below 0.15.
  • Approximate: ΔE of 0.15 or more.

These badge limits are set by this tool. They are not part of Tailwind or a color standard.

Worked example: #4080ff

#4080ff is not in the palette. Its nearest match is blue-500 (#3b82f6) at ΔE 0.015, which gets the Very close badge. Next come indigo-500 at 0.067 and indigo-400 at 0.082, both marked Close.

When the Nearest Class Is Not Close Enough

A Close or Approximate match changes the color visibly. For a brand color, keep the exact value with an arbitrary value class such as bg-[#4080ff], or add the color to your theme.

Tailwind Matching Questions

Is the v4 value the same as in the Tailwind v4 source?

Yes. The OKLCH string and the v4 button use the values from the default palette in the Tailwind v4 package, the same ones Tailwind v4 puts in its theme. The match itself is still found in the v3 HEX palette, and the v4 color for a class can look slightly different from its v3 HEX.

Does the tool read my custom Tailwind theme?

No. It only searches the built-in default palette. Colors added in your own config are not included.

Can I enter a 3-digit HEX code?

No. The input needs six digits, such as #3b82f6. Expand shorthand by doubling each digit: #38f becomes #3388ff.

Related Color Tools