🔁 HEX ⇄ RGB Converter

Paste a hex code or RGB values — the other format fills in as you type, with HSL as a bonus and a live swatch so you can see what you're converting.

How hex and RGB relate

They're the same numbers in different clothes. A hex code is three bytes written in base-16 — #6366f1 splits into 63, 66, f1, which in decimal are 99, 102, 241: your red, green, and blue channels out of 255. The 3-digit shorthand doubles each digit (#f0c = #ff00cc). HSL re-expresses the same color as hue (0–360°), saturation, and lightness — far friendlier when you want "the same blue, but lighter."

Which format to use where

CSS accepts all three. Hex is compact and universal in design tools; RGB is what canvas APIs and image data speak; HSL is best for programmatic variations (hover states, tint ramps). For transparency, hex extends to 8 digits (#RRGGBBAA) and the functional forms take a fourth alpha value.

Frequently asked questions

How do I convert hex to RGB by hand?

Split the six digits into pairs and convert each pair from base-16: multiply the first digit's value by 16 and add the second. F1 = 15×16 + 1 = 241. Letters run A=10 through F=15.

What's the difference between #fff and #ffffff?

None — 3-digit hex is shorthand where each digit doubles. #fff expands to #ffffff (white), #f0c to #ff00cc. Both are valid CSS.

Does this converter support alpha (transparency)?

It converts opaque colors; for transparency append alpha yourself — hex #6366f180 (≈50%) or rgba(99, 102, 241, 0.5). The RGB numbers stay identical.

Why do the same RGB values look different on two screens?

Monitor color profiles differ. The numbers define the color in sRGB; uncalibrated screens render it their own way. For print or brand-critical work, check colors on a calibrated display.