Tailwind color class converter: why your HEX doesn't match

Contents
When a designer hands you a HEX color like #5D63E6, it's no surprise that it doesn't exactly match Tailwind's indigo-500 (#6366F1). The default Tailwind palette is fixed at 22 color families × 11 steps (50–950), and the odds that any random brand color happens to land on one of those 242 values are low. So what you need isn't an "exact match" class — it's a rule for picking the closest one.
Summary ① The default Tailwind palette is 22 families × 11 steps, with all 242 HEX values fixed individually per family. ② To pick the closest class, you need a color distance calculation (redmean) that reflects how human eyes actually perceive color differences. ③ If all five candidates come back with large distance values, the color probably doesn't exist in the default Tailwind palette at all.
The problem: brand colors don't sit on the Tailwind palette
Say you need to turn a brand color from a Figma mockup into a Tailwind class like bg-{color}-{step}. You can't just use #5D63E6 as-is, so you have to decide which family — indigo, blue, or violet — and which step comes closest.
The catch is that Tailwind's 50–900 (950) steps aren't a brightness range split by some formula. Each family and each step is its own fixed HEX value, so you can't back into it with arithmetic like "brightness ÷ 9 steps."
Because of that, people often eyeball it and say "this is probably indigo-500" and move on. But if you pick the wrong family — violet when it should be indigo, say — the whole screen's color cast ends up subtly off, and it stays that way.
The fix: measure the color distance instead of eyeballing it
The quantitative way to pick the closest color is to reduce the RGB difference between two colors to a single number (a distance) and find the smallest one. You could use plain Euclidean distance, adding up the R, G, and B differences, but human eyes don't weight all three channels equally.
Redmean is an approximation that accounts for the fact that eyes are more sensitive to differences in the green channel, and that the perceived difference in red and blue depends on overall brightness (redness). Here's the formula.
rm = (R1 + R2) / 2
Δ = √[ (2 + rm/256) × (R1-R2)² + 4 × (G1-G2)² + (2 + (255-rm)/256) × (B1-B2)² ]
Worked out by hand, it looks like this. Comparing the brand color #5D63E6 (R93 G99 B230) with indigo-500 #6366F1 (R99 G102 B241) gives rm=96 and Δ≈20.9. Comparing the same color with blue-600 #2563EB (R37 G99 B235) gives rm=65 and Δ≈84.5 — much farther away.
Just from the numbers you can see indigo-500 is 4× closer than blue-600. The problem is that you'd have to repeat this calculation by hand for every candidate. With 22 families and 11 steps, checking everything means 242 calculations.
Our tool runs those 242 calculations for you and shows the top 5 sorted by distance right away.
No install or sign-up. It runs right in your browser, and the color values you enter are never sent to a server.

Where people get stuck
| Situation | What actually happens |
|---|---|
A 3-digit HEX like #fff | Each digit is doubled to expand it to 6 digits, then read |
Entering the rgb(93, 99, 230) format | It isn't recognized. Convert it to HEX (#RRGGBB) first |
| A HEX with whitespace or a length error | No calculation runs; you just get a format error message |
| Theme colors customized in your Tailwind config | They're not match targets. Only the default 22 families are compared |
| An absolute cutoff for "close enough" on Δ | There is no fixed threshold, so it's safer to put the candidate on screen and compare it by eye |
The third and fourth items are the ones people miss most often. If your project added brand-specific colors to tailwind.config, those colors aren't among the 242 candidates the tool compares — so no matter how close a match you pick, it won't be the original color.
Recap
- The default Tailwind palette is 22 families × 11 steps, 242 fixed HEX values total. They aren't generated by a per-family formula; each value is set individually.
- To find the closest class to any HEX, use redmean distance — which accounts for how sensitive human eyes are to each channel — rather than Euclidean distance. It tracks real perception better.
- Doing it by hand means computing rm=(R1+R2)/2 and plugging it into the formula above, but when you have many candidates, sorting them all at once with a tool is faster.
- If all five candidates come back with large Δ values, you're better off using a project-specific custom color than a default Tailwind one, in terms of color accuracy.
- Conversely, if you already know the family and step, the Class → HEX tab gives you the exact HEX and RGB values instantly.
No install or sign-up. It runs right in your browser, and the color values you enter are never sent to a server.
Frequently asked questions
Does it convert custom Tailwind theme colors too?
No. This tool only compares against the default Tailwind CSS palette (22 families × 11 steps). Brand colors you add or override in tailwind.config aren't in the list of 242 candidates, so a search for one will always return only "the closest default color."
How small does the Δ (delta) value need to be to count as "close enough"?
There's no fixed threshold. Δ is a relative color distance calculated with the redmean method, so while a smaller value clearly means closer to the original, an absolute cutoff like "under 10 is a pass" varies with the color combination and the display setup. It's safer to place the candidate on the actual screen background and compare it once by eye.
I only know the class name: how do I find the exact HEX value?
Use the Class → HEX tab and pick the color family and shade from their dropdowns. For example, choose sky and 600, and the exact HEX and RGB values for that class appear right away, with separate copy buttons for the HEX value and for the class name in bg-sky-600 form.
This article was adapted from our Korean original. Read the Korean original