Tailwind Color Converter

Find the closest Tailwind CSS colour class to any hex — the nearest match from Tailwind's core swatches, with the ready-to-use class name. Runs in your browser.

Color Tools Free No upload Instant

Loading Tailwind Color Converter…

Your browser is preparing the tool. It runs 100% locally.

Quick Answer

Enter a hex colour and the tool returns the nearest Tailwind CSS colour — its class name (such as bg-blue-600) and the swatch's hex. It compares your colour against a curated set of Tailwind's core swatches by straight-line distance in RGB. Because it uses a subset (mostly the -500 shades), treat the result as a close class to start from, not Tailwind's exact nearest shade. It runs in your browser.

What the Tailwind Color Converter Does

Give it a hex code and it tells you the closest Tailwind colour class plus that swatch's hex, so you can drop a Tailwind utility like bg-blue-600 into your markup instead of a hard-coded value.

It is the quick bridge from a design colour to Tailwind's naming — handy when a mockup uses a raw hex and you want the nearest first-party class to keep your styles consistent with the framework.

How It Works

The tool keeps a list of Tailwind's core swatches with their hex values. When you enter a colour, it converts it to RGB and measures the straight-line distance to each swatch, treating red, green and blue as coordinates.

The swatch with the smallest distance is reported, and the tool builds the matching class name (for example bg-blue-600) from it. The match is fast and repeatable, but the list is a curated subset of Tailwind's full palette, so it points you to a close class rather than scanning every shade.

Data source & conversion logic

  1. Convert the hex to RGB. Read your colour as red, green and blue from 0 to 255.
  2. Compare to each Tailwind swatch. Measure the straight-line RGB distance to every swatch in the list.
  3. Pick the nearest. The swatch with the smallest distance is the closest Tailwind colour.
  4. Build the class name. Report the swatch, its hex, and the ready-to-use class such as bg-blue-600.

Nearest-swatch distance

for each Tailwind swatch: distance squared = (R − Rs)² + (G − Gs)² + (B − Bs)² the swatch with the smallest distance wins → bg-(name)
Worked example
#2563EB → bg-blue-600 (exact) · #7C3AED → bg-violet-500

The list is mostly the -500 shades plus a few blues and a dark slate, so most matches land on a -500 class even when a lighter or darker shade would be a touch closer.

Standards & references

  • Tailwind CSS colour palette — Tailwind ships a large default palette — around 22 hues across 11 shades each (50 to 950). This tool matches against a curated subset of those swatches, not every shade.
  • Euclidean RGB distance — Closeness is the straight-line distance between two colours in the RGB cube — simple and fast, but not perceptually uniform.
  • Tailwind utility classes — Colours are applied as classes like bg-blue-600 or text-rose-500. The tool returns the class name so you can paste it straight into your markup.

Accuracy & Limitations

The match is exact maths, but against a subset. Because the list is mostly -500 shades, your colour usually snaps to a -500 class even when the real nearest in the full palette is a lighter or darker step. Read it as a close starting class.

Distance is measured in raw RGB, which is not how the eye judges colour. Occasionally a swatch that is slightly farther in numbers would look closer, so the nearest-by-distance is approximate.

It returns one class. Tailwind's full palette has many shades per hue, and the exact best fit might be, say, blue-600 versus blue-700 — a difference this subset may not capture. Check the shade ladder in your config to fine-tune.

The class name assumes the default Tailwind palette. If your project customises or renames colours, the suggested class may not exist as-is and will need mapping to your own scale.

Real-World Use Cases

Matching a design to Tailwind

Turn a mockup's hex into the nearest first-party class.

Keeping styles consistent

Use framework classes instead of scattered hex values.

Quick prototyping

Grab a close bg- or text- class without opening the palette docs.

Learning the palette

See which Tailwind colour a hex is nearest to.

When to use it — and when not to

Good for

  • A close Tailwind class for a hex
  • Bridging a design colour to the framework
  • Quick prototyping with utility classes
  • Getting into Tailwind's naming

Not the best choice for

  • The exact best shade across all 50-950 steps
  • A customised or renamed project palette
  • Perceptually exact matching
  • Non-Tailwind projects

For the precise shade, compare against Tailwind's full colour scale in the docs or your tailwind.config. For a custom palette, map the hex to your own tokens. For an exact colour rather than a class, keep the hex with a hex-to-RGB or HSL converter.

Frequently Asked Questions

How does it find the nearest Tailwind colour?
It converts your hex to RGB and measures the straight-line distance to each swatch in its list, then reports the closest and builds the class name, such as bg-blue-600.
Does it check Tailwind's whole palette?
No. It uses a curated subset, mostly the -500 shades plus a few extra blues and a dark slate. So it points you to a close class, not necessarily the exact nearest of all 50-to-950 shades.
Why does it usually pick a -500 class?
Because the list is weighted toward the -500 shades. Even when a lighter or darker step would be marginally closer, the match lands on the nearest swatch it knows, which is often a -500.
Is the class name ready to use?
Yes. It returns the class in Tailwind form (for example bg-blue-600). You can swap the prefix for text-, border- and so on as needed.
Will the suggested class exist in my project?
It assumes the default Tailwind palette. If you have customised or renamed colours, map the suggestion to your own scale — the class name may differ.
What is Euclidean RGB distance?
It treats red, green and blue as coordinates and measures the straight-line gap between two colours. It is fast and deterministic but not perceptually uniform.
Does it give an exact match for a Tailwind hex?
Yes. If your hex equals a swatch in the list (for example #2563EB for blue-600), the distance is zero and you get that exact class.
How do I pick between, say, blue-600 and blue-700?
This subset may report just one. To fine-tune the shade, look at the blue scale in the Tailwind docs or your config and choose the step that matches your design intent.
Can I get text or border classes instead of bg?
The tool returns a bg- class, but the colour name is the same across utilities. Replace bg- with text-, border-, ring- and so on to apply it elsewhere.
Why might a vivid colour match a duller swatch?
If your colour sits outside the range the subset covers well, the nearest-by-distance swatch can be less saturated. The full palette might hold a closer hue; this list is a curated shortcut.
Is my colour uploaded?
No. The match runs in your browser against a built-in list; nothing is sent anywhere.
Does this work for Tailwind v3 and v4?
The class naming (bg-blue-600 and the like) is consistent across recent Tailwind versions, so the suggestion applies. Always confirm the exact hex against the palette in your installed version.

References

Matches against a curated set of Tailwind swatches (mostly the -500 shades) by RGB distance; honest that it is a subset of the full palette and a starting point, not an exact shade lookup.

PopularHot

Color Picker

Use Color Picker to choose and convert color precisely — instant and free.

ColorOpen Tool
Popular

HEX to RGB Converter

Use HEX to RGB Converter to choose and convert color precisely — instant and free.

ColorOpen Tool
Trending

Color Palette Generator

Use Color Palette Generator to choose and convert color precisely — instant and free.

ColorOpen Tool
Trending

Gradient Generator

Use Gradient Generator to choose and convert color precisely — instant and free.

ColorOpen Tool
Editor's Pick

Contrast Checker

Use Contrast Checker to choose and convert color precisely — instant and free.

ColorOpen Tool

RGB to HEX Converter

RGB to HEX Converter with copy-ready values for design and front-end work.

ColorOpen Tool

Ready to try the Tailwind Color Converter?

It is free, private and runs entirely in your browser — no sign-up, no uploads, no limits.