Skip to tool

Color Converter

Color
Paste or type HEX, RGB, HSL, HWB, OKLCH or a CSS color name, then press Enter.
Adjust
°
%
%
HEXExample values
#2563EB

oklch(54.6% 0.215 262.9)

RGB
rgb(37 99 235)
RGBA
rgba(37 99 235 / 1)
HSL
hsl(221 83.2% 53.3%)
HSLA
hsla(221 83.2% 53.3% / 1)
HWB
hwb(221 14.5% 7.8%)
OKLCH
oklch(54.6% 0.215 262.9)
WCAG contrast
vs white
5.17:1AA large / UI: PassAA: PassAAA: Fail
vs black
4.06:1AA large / UI: PassAA: FailAAA: Fail
vs custom
1.15:1AA large / UI: FailAA: FailAAA: Fail
Nearest Tailwind color
Exact match
blue-600
Recent

No history yet

ShadesGenerated in OKLCH for perceptual uniformity
50
100
200
300
400
500
600
700
800
900
950

Convert HEX to RGB, HSL, HWB and OKLCH

Paste a color in any CSS form: HEX with 3, 4, 6 or 8 digits (with or without #), rgb() or rgba(), hsl() or hsla(), hwb(), oklch(), a named color such as tomato, or transparent. Both the comma syntax and the CSS Color 4 space syntax work, and alpha can be 0–1 or a percentage. The tool returns HEX, RGB, RGBA, HSL, HSLA, HWB, OKLCH and the CSS color name when one matches, plus WCAG contrast, an 11-step OKLCH shade scale and the nearest Tailwind class. For example, #FF6347 converts to rgb(255 99 71), hsl(9 100% 63.9%) and oklch(69.6% 0.196 32.3), and its CSS name is tomato.

How to convert HEX to RGB and RGB to HEX by hand

A 6-digit HEX code is three base-16 pairs for red, green and blue. Convert each pair to decimal: FF = 15 × 16 + 15 = 255, 63 = 6 × 16 + 3 = 99, 47 = 4 × 16 + 7 = 71, so #FF6347 is rgb(255 99 71). A 3-digit code doubles each digit, so #F0A is #FF00AA. An 8-digit code adds an alpha pair: 80 is 128, and 128 / 255 ≈ 0.5 opacity. To go back from RGB to HEX, divide each channel by 16 and write the quotient and remainder as hex digits: 99 ÷ 16 = 6 remainder 3, so 99 is 63.

What is OKLCH?

OKLCH is a color space defined in CSS Color Module Level 4, written as lightness (0–100%), chroma (about 0–0.4) and hue (0–360°). It is designed to be perceptually uniform: equal numeric steps look like roughly equal visual steps. HSL is not; yellow at 50% lightness looks much brighter than blue at 50% lightness. That is why the shade scale here changes OKLCH lightness in steps of 0.05 while keeping chroma and hue fixed.

How does the WCAG contrast checker work?

The contrast ratio is (L1 + 0.05) / (L2 + 0.05), where L1 and L2 are the relative luminance of the lighter and darker color (0.2126 R + 0.7152 G + 0.0722 B on linearized sRGB channels). WCAG AA requires at least 4.5:1 for body text and 3:1 for large text and UI components; AAA requires 7:1 for body text. The checker compares your color with white, black and a custom color. Tomato (#FF6347) gives 2.95:1 on white, which fails AA for text, and 7.13:1 on black, which passes AAA.

FAQ

Why are some OKLCH colors marked as clipped?

OKLCH can describe colors outside the sRGB gamut that HEX and RGB can represent. When the chroma is too high for a given lightness and hue, each RGB channel is clamped to 0–255 and the result is marked as clipped. For example, oklch(70% 0.4 30) becomes #FF0000, which is close but not identical to the requested color.

Why use OKLCH instead of HSL for design tokens?

In OKLCH, the same lightness value looks about equally light across hues, so a scale built by stepping lightness stays visually even. In HSL, hsl(60 100% 50%) yellow and hsl(240 100% 50%) blue share 50% lightness but look very different, so scales drift.

What WCAG contrast level should I aim for?

AA is the usual target: 4.5:1 for body text and 3:1 for large text (24 px, or 18.66 px bold) and UI components. Accessibility rules such as US Section 508 and the EU standard EN 301 549 reference WCAG level AA. AAA (7:1 for body text) is stricter and is often used for long-form reading.

What is the difference between RGB and RGBA?

RGBA adds an alpha (opacity) channel from 0 to 1. In CSS Color 4, rgb() also accepts alpha, as in rgb(255 99 71 / 0.5), so rgba() is kept for older code. The same applies to hsl() and hsla(). In HEX, alpha is the fourth or eighth digit pair, as in #FF634780.

How do I convert RGBA to HEX?

Convert R, G and B to two-digit HEX as usual, then multiply the alpha by 255, round, and convert that too: 0.5 × 255 = 127.5, which rounds to 128, or 80 in HEX. So rgba(255, 99, 71, 0.5) becomes #FF634780. Paste an rgba() value here and the HEX row shows the 8-digit code; a fully opaque color gives the 6-digit form.

How is the nearest Tailwind color chosen?

The tool measures the distance in OKLCH between your color and each shade of Tailwind's default palette (22 hues × 11 shades) and picks the closest. A distance below 0.005 is shown as an exact match; #2563EB, for example, is exactly blue-600.

Can I share a color via URL?

Yes. The URL hash updates as you change the color, so copying the address bar gives a link that opens the same color.