What is a HEX to RGB Converter?
HEX and RGB are two different ways of writing down the exact same color information for use in CSS, design tools, and image editors. HEX (like #3B82F6) packs red, green, and blue values into a six-digit hexadecimal string, while RGB (like rgb(59, 130, 246)) writes those same three values out as plain decimal numbers from 0-255. Neither format is more 'correct' — different tools and codebases just have different conventions, and this converter exists because you'll regularly need to translate between them (a design tool exports HEX, but a JavaScript animation library expects RGB values you can interpolate between, for example).
When to use it
This comes up constantly in frontend work: a designer hands you a HEX code from Figma, but you're writing JavaScript that needs individual R, G, B channels to calculate opacity or blend colors. Or the reverse — you're reading a color out of a canvas pixel (which gives RGB) and need to write it into a CSS class as HEX. It's also useful for quickly sanity-checking a color value someone sent you looks like what you expect, using the live swatch preview.
How it works
Converting HEX to RGB is base conversion: each pair of hex digits (00-FF) represents one color channel and converts directly to its decimal equivalent (0-255) — for example, hex 3B is 59 in decimal, which becomes the red value in rgb(59, 130, 246). Converting the other direction reverses this, formatting each decimal channel value back into two-digit hexadecimal and concatenating them with a # prefix. This is exact, lossless math in both directions — there's no rounding or approximation, since both formats represent the same underlying 24-bit color value.
Frequently asked questions
Why do some HEX codes have 3 digits and others have 6?
A 3-digit HEX code (like #3BF) is shorthand where each digit is doubled to form the full 6-digit value (#33BBFF) — it only works when both digits in each channel pair are identical. Most colors need the full 6-digit form; the 3-digit shorthand is just a CSS convenience for colors that happen to fit the pattern.
What's the difference between RGB and RGBA?
RGBA adds a fourth value — alpha — controlling transparency, from 0 (fully transparent) to 1 (fully opaque). Plain RGB and HEX have no transparency information; if you need to convert a color that includes opacity, you'll need the RGBA or 8-digit HEX (#RRGGBBAA) format specifically.
Can I convert HEX or RGB to HSL instead?
This tool focuses on HEX/RGB conversion, but the Palette Generator tool on this site works internally with HSL and can help you explore related shades, tints, and complementary colors from a base HEX value.