How to Convert HEX to RGB (and RGB to HEX) for CSS
Your design file hands you #3B82F6, but the CSS you are writing needs rgba() so you can fade the color to 50% opacity. Or you have an rgb()value from a screenshot tool and need the HEX to paste into a style guide. Either way, you need to convert — and doing the base-16 math in your head is no fun.
A color converter does it exactly, both directions. Here is how.
How to convert HEX to RGB (and back) for CSS
QuickWand's free color converter runs in your browser — type a color and read the result, with nothing sent to a server.
- Open the color converter.
- Enter your color in any format — a HEX value like
#3B82F6, anrgb(59, 130, 246)value, or an HSL value. - Read the equivalent values in the other formats, updated as you type.
- Copy the format you need and paste it into your CSS or design tool.
How HEX and RGB actually relate
The conversion feels like magic but it is just arithmetic. A HEX color is RGB written in base 16. The six digits are three pairs, one each for red, green, and blue, and each pair is a number from 00 to FF — which is 0 to 255 in everyday base-10 numbers.
Take #3B82F6:
3B→ 59 (red)82→ 130 (green)F6→ 246 (blue)
So #3B82F6 is exactly rgb(59, 130, 246). Because it is a direct base conversion, it is lossless in both directions — HEX to RGB and RGB to HEX describe the identical color with no rounding.
Where HSL comes in
HSL describes the same color as hue, saturation, and lightnessinstead of red/green/blue channels. It does not give you a different color — it gives you a more intuitive set of dials. Want a slightly darker shade of a brand color? Drop the lightness a few percent. The converter shows HSL alongside HEX and RGB so you can switch to whichever is easiest for the job.
When to reach for rgb() or rgba()
HEX is compact and great for solid colors. Reach for rgb() or rgba() when you need transparency: rgba(59, 130, 246, 0.5)is the same blue at half opacity — perfect for overlays, hover tints, and subtle backgrounds. Modern CSS also accepts 8-digit HEX like #3B82F680 for alpha, but the rgba() form is usually easier to read and tweak.
If you are also naming the CSS classes or variables for these colors, the case converter turns a label like Primary Blue into a tidy primary-blue kebab-case class name.
Type a color in any format, copy the one you need — an exact, lossless conversion every time.