Tailwind Color Finder

Find the nearest Tailwind CSS color class for any HEX or RGB value

Try an example

Color (HEX)

Nearest Tailwind colors

Click any result to copy the class name

What Is a Tailwind Color Finder?

Tailwind CSS ships with a default color palette of 22 color families, each containing 11 shades from 50 (lightest) to 950 (darkest). That gives you 242 predefined colors with class names like bg-indigo-500 or text-red-400. When you have a hex or RGB value from a design file and need to find the closest Tailwind class, a Tailwind color finder calculates the distance between your input and every color in the palette, then returns the best matches.

The matching process works by converting both your input color and each Tailwind color to RGB triplets, then computing the Euclidean distance in 3D color space: sqrt((r1-r2)^2 + (g1-g2)^2 + (b1-b2)^2). The Tailwind color with the smallest distance is the nearest match. If the distance is zero, your input maps exactly to a Tailwind default shade.

This is different from a general color converter or color name finder. A converter changes formats (hex to HSL, RGB to CMYK). A name finder matches against the 148 CSS named colors. A Tailwind color finder matches specifically against the Tailwind CSS default palette, returning class names you can paste directly into your markup.

Why Use This Tailwind Color Finder?

Manually comparing a hex value against 242 Tailwind shades means scrolling through documentation or config files. This tool runs the distance calculation for every shade and shows the top matches ranked by proximity, with their exact hex values and Tailwind class names ready to copy.

🎯
Map Any Color to Tailwind Classes
Paste a hex code from Figma, Sketch, or a brand guideline and get the nearest Tailwind color class instantly. The tool returns multiple ranked matches so you can pick the shade that fits your design intent.
πŸ”’
Privacy-first Processing
All color calculations run in your browser. No color values are sent to any server. The tool works offline after the page loads.
⚑
Instant Matching on Every Keystroke
Change a single character in the hex input and the results recalculate immediately. No submit button, no loading spinner, no round-trip to a backend.
πŸ“‹
Copy Class Names Directly
Click any result to copy the Tailwind class name (like indigo-500) to your clipboard. Paste it into your JSX, HTML, or Tailwind config without reformatting.

Tailwind Color Finder Use Cases

Design-to-Code Translation
Frontend developers receiving hex values from a Figma design can find the nearest Tailwind class instead of adding custom colors. This keeps the codebase aligned with the default palette and reduces tailwind.config.js bloat.
Migrating Existing CSS to Tailwind
Backend engineers converting a legacy project to Tailwind CSS can look up each existing hex color and replace it with the closest utility class. This speeds up migration without re-choosing every color from scratch.
Design System Auditing
DevOps and platform teams auditing a Tailwind-based design system can check which custom colors are close enough to default shades to be replaced, reducing palette maintenance overhead.
Component Library Development
QA engineers testing a component library can verify that rendered colors match expected Tailwind shades by pasting sampled hex values into the finder and checking the distance score.
Data Dashboard Theming
Data engineers building dashboards with Tailwind-styled chart libraries can map brand colors or client-provided hex values to the nearest Tailwind shade for consistent theming across components.
Learning the Tailwind Palette
Students and developers new to Tailwind CSS can type arbitrary hex values and explore which palette family and shade number they land in, building familiarity with color-500 vs color-700 distinctions.

Tailwind CSS Default Color Palette

Tailwind CSS v3 includes 22 color families. Each family has 11 shades: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, and 950. The 500 shade is considered the 'base' for each family. The table below lists every family with its lightest (50) and darkest (950) hex values.

Color familyShades50 (lightest)950 (darkest)
slate11#f8fafc#020617
gray11#f9fafb#030712
zinc11#fafafa#09090b
neutral11#fafafa#0a0a0a
stone11#fafaf9#0c0a09
red11#fef2f2#450a0a
orange11#fff7ed#431407
amber11#fffbeb#451a03
yellow11#fefce8#422006
lime11#f7fee7#1a2e05
green11#f0fdf4#052e16
emerald11#ecfdf5#022c22
teal11#f0fdfa#042f2e
cyan11#ecfeff#083344
sky11#f0f9ff#082f49
blue11#eff6ff#172554
indigo11#eef2ff#1e1b4b
violet11#f5f3ff#2e1065
purple11#faf5ff#3b0764
fuchsia11#fdf4ff#350820
pink11#fdf2f8#500724
rose11#fff1f2#4c0519

Tailwind v3 vs v4 Color Palette

Tailwind CSS v4 changes how colors are defined but keeps the same default palette names and shade numbers.

Tailwind CSS v3
Colors are defined in tailwind.config.js as hex values. The default palette includes 22 color families (slate through rose) with 11 shades each (50-950). Custom colors are added via theme.extend.colors. Class names follow the pattern bg-{color}-{shade}, text-{color}-{shade}, etc.
Tailwind CSS v4
Colors move to CSS custom properties defined in @theme. The default palette is the same 22 families and 11 shades, but values are stored as OKLCH instead of hex. Custom colors use @theme { --color-brand: oklch(0.5 0.2 240); }. Class names are unchanged: bg-brand, text-indigo-500, etc.

Code Examples

Find the nearest Tailwind color programmatically using Euclidean distance in RGB space. Each example takes a hex string and returns the closest Tailwind class name from the default palette.

JavaScript
// Find nearest Tailwind color from hex input
const TAILWIND_COLORS = {
  'red-500': [239, 68, 68],
  'blue-500': [59, 130, 246],
  'indigo-500': [99, 102, 241],
  'green-500': [34, 197, 94],
  // ... full palette (242 entries)
}

function hexToRgb(hex) {
  const n = parseInt(hex.replace('#', ''), 16)
  return [(n >> 16) & 255, (n >> 8) & 255, n & 255]
}

function nearestTailwind(hex) {
  const [r, g, b] = hexToRgb(hex)
  let best = '', bestDist = Infinity
  for (const [name, [r2, g2, b2]] of Object.entries(TAILWIND_COLORS)) {
    const d = Math.sqrt((r - r2) ** 2 + (g - g2) ** 2 + (b - b2) ** 2)
    if (d < bestDist) { bestDist = d; best = name }
  }
  return best
}

nearestTailwind('#6366f1') // β†’ "indigo-500" (exact match)
nearestTailwind('#5a5de0') // β†’ "indigo-500" (distance: 19.3)
nearestTailwind('#ff4500') // β†’ "red-500" (distance: 57.2)
Python
import math

TAILWIND = {
    "red-500": (239, 68, 68),
    "blue-500": (59, 130, 246),
    "indigo-500": (99, 102, 241),
    "green-500": (34, 197, 94),
    # ... full palette
}

def hex_to_rgb(h: str) -> tuple[int, int, int]:
    h = h.lstrip("#")
    return int(h[0:2], 16), int(h[2:4], 16), int(h[4:6], 16)

def nearest_tailwind(hex_str: str) -> tuple[str, float]:
    r, g, b = hex_to_rgb(hex_str)
    name, dist = min(
        TAILWIND.items(),
        key=lambda item: math.dist((r, g, b), item[1])
    )
    return name, round(dist, 1)

print(nearest_tailwind("#6366f1"))  # β†’ ('indigo-500', 0.0)
print(nearest_tailwind("#1e293b"))  # β†’ ('slate-800', 0.0)
print(nearest_tailwind("#333333"))  # β†’ ('zinc-700', 17.5)
CLI (Tailwind config)
# tailwind.config.js β€” extend palette with a custom color
# mapped to its nearest default Tailwind shade
module.exports = {
  theme: {
    extend: {
      colors: {
        brand: {
          // Your brand color: #5a5de0
          // Nearest Tailwind: indigo-500 (#6366f1)
          // Use the exact brand color, reference Tailwind for context
          DEFAULT: '#5a5de0',
          light: '#8183f0',   // near indigo-300
          dark: '#3b3dab',    // near indigo-700
        }
      }
    }
  }
}

# Check Tailwind classes in markup:
# npx tailwindcss -o output.css --content ./src/**/*.html

Frequently Asked Questions

How many colors are in the Tailwind CSS default palette?
The default palette in Tailwind CSS v3 and v4 contains 242 colors: 22 color families (slate, gray, zinc, neutral, stone, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose) with 11 shades each (50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950). Black and white are also available as standalone utilities.
What is the difference between a Tailwind color finder and a CSS color name finder?
A CSS color name finder matches your input against the 148 CSS named colors (like Tomato, SlateBlue, or Crimson). A Tailwind color finder matches against the 242 colors in the Tailwind default palette and returns class names like red-500 or indigo-400. The output of a Tailwind finder is a utility class you can use directly in your HTML or JSX.
Can I use this tool for Tailwind CSS v4 projects?
Yes. The default color palette in Tailwind v4 uses the same color names and shade numbers as v3. The hex values are nearly identical. The main difference is that v4 stores colors internally as OKLCH, but the visual output matches v3 for the standard palette. If you have customized your v4 theme with non-default OKLCH values, the finder matches against the standard palette only.
What does the distance score mean in the results?
The distance score is the Euclidean distance between your input color and the matched Tailwind color in RGB space. A distance of 0 means an exact match. A distance under 10 is very close and usually indistinguishable to the human eye. Distances above 30 indicate a noticeable difference. The score helps you decide whether to use the suggested Tailwind class or add a custom color.
Should I always use the nearest Tailwind color instead of a custom hex?
Not always. If the distance to the nearest Tailwind shade is small (under 10-15), switching to the default class reduces your config size and keeps your palette consistent. If the distance is large, or the color is a specific brand color that must match exactly, add it as a custom color in your Tailwind config. The finder helps you make that decision by showing the exact distance.
Why are there five gray families (slate, gray, zinc, neutral, stone)?
Each gray family has a different undertone. Slate has a blue tint, suitable for UI designs with blue accents. Gray is a balanced warm-cool neutral. Zinc skews slightly cool without being blue. Neutral is a true achromatic gray with no color bias. Stone has a warm brown undertone. Tailwind includes all five so you can match grays to your design's color temperature without custom configuration.
How do I add the matched color to my Tailwind project?
If the match is an exact or near-exact default shade, use the class name directly: bg-indigo-500, text-red-400, border-emerald-600. No config changes needed. If you want to use a custom color that is close but not identical to a Tailwind shade, add it to your tailwind.config.js under theme.extend.colors (v3) or as a CSS custom property in @theme (v4). The finder gives you the class name format to use in either case.