~ / developer / color-converter

◐ Color Converter

HEX ↔ RGB ↔ HSL, a Tailwind-style shade palette and a WCAG contrast checker. Type in any box and the rest follow.

#C6FF3D click to pick
shades — 50 → 950 · click to copy HEX
contrast checker (WCAG 2.x)
The quick smith lab
This is how body text looks. 0123456789
Small caption text · fine print
—

How to use the color converter

  1. Type a color into the hex, rgb or hsl box and the other formats fill in automatically. You can also click the big swatch on the left to open your system color picker.
  2. Use copy next to each box. The css var row gives you a ready-made --color-brand: #HEX; custom property declaration.
  3. shades builds an 11-step 50–950 palette with the same hue and saturation but different lightness. Click a tile to copy its HEX, or copy as css to grab all eleven --brand-50 … --brand-950 variables.
  4. In the contrast checker, set a text color and a background color to see the contrast ratio and WCAG pass/fail results. swap ⇄ flips the two.

If the URL ends with a HEX value like #FF6600, the page starts with that color, and the URL updates as you change colors — so you can share a link to an exact color.

HEX vs. RGB vs. HSL

FormatExampleBest for
HEX#FF6600 / #F60Design hand-off, CSS, brand guides — compact and copy-paste friendly
RGBrgb(255, 102, 0)Math and code (canvas, image processing); same data as HEX in base 10
HSLhsl(24, 100%, 50%)Tweaking: "a bit darker," "less saturated," building palettes

How to convert HEX to RGB by hand

Split the six digits into three pairs and convert each pair from base 16 to base 10: #C6FF3D → C6 = 12×16 + 6 = 198, FF = 255, 3D = 3×16 + 13 = 61 → rgb(198, 255, 61). Going the other way, divide each channel by 16: the quotient is the first hex digit and the remainder the second. Our number base converter shows the same hex ↔ decimal math step by step.

How the shade palette is built

Your color is converted to HSL. Hue and saturation stay fixed, and lightness is set to 97, 93, 85, 75, 63, 52, 43, 35, 27, 20, 12% to create 11 steps. Lower numbers are lighter; 500 is roughly the mid-tone near your base color. A common pattern: buttons at 500–600, hover one step darker, subtle background boxes at 50–100, body text at 800–950. The label on each tile switches between black and white automatically so it stays readable.

WCAG contrast ratio requirements

Contrast ratio is (Llighter + 0.05) ÷ (Ldarker + 0.05), where L is each color's relative luminance. It ranges from 1:1 (same color) to 21:1 (black on white).

LevelNormal textLarge text
AA (minimum, required by most US accessibility policies)4.5 : 13 : 1
AAA (enhanced)7 : 14.5 : 1

"Large text" means at least 18pt (24px) regular, or 14pt (about 18.7px) bold. UI components and icons also need 3:1 against adjacent colors under WCAG 2.1.

Alpha transparency isn't supported: the alpha value in rgba() / hsla() is ignored and 8-digit HEX (#RRGGBBAA) isn't recognized. The shade palette uses fixed HSL lightness steps, so it won't exactly match Tailwind's default palette. Everything runs in your browser.

FAQ

How do I convert HEX to RGB?
Split the HEX code into three pairs and convert each from hexadecimal to decimal. #C6FF3D → C6 = 198, FF = 255, 3D = 61, so rgb(198, 255, 61). Or just paste it into the hex box above.
What contrast ratio do I need for accessibility?
WCAG 2.x level AA requires 4.5:1 for normal body text and 3:1 for large text (24px+, or 18.7px+ bold). Level AAA raises that to 7:1 and 4.5:1.
My colors fail the 4.5:1 contrast check. How do I fix it?
Adjusting HSL lightness is the easiest fix. Pick a darker step (700–900) from the shades palette for the text color, or a lighter one for the background, and re-check.
Why did the input box turn red?
The value wasn't recognized. HEX must be 3 or 6 digits, RGB channels 0–255, and HSL saturation and lightness 0–100.
What is the difference between RGB and HSL?
They describe the same colors. RGB mixes red, green and blue light; HSL describes hue, saturation and lightness, which makes it much easier to create lighter or darker variations of one color.

Related tools