Hex to RGB Converter (and RGB to Hex)
Convert a hex color like #3B82F6 to RGB 0–255 and back, pick a color visually, and copy ready-to-use CSS rgb(), hsl(), and hex strings.
#3B82F6rgb(59, 130, 246)hsl(217, 91%, 60%)Hex and RGB color
A hex color is just an RGB color written in base 16. The six digits are three pairs — red, green, and blue — each a value from00 to FF, which is 0 to 255 in decimal. So#3B82F6 means red = 0x3B = 59, green = 0x82 = 130, blue = 0xF6 = 246, the same color as rgb(59, 130, 246).
R,G,B (0–255) → hex: each channel as two base-16 digits
hex → R,G,B: read each pair of digits back as a number
This tool keeps the picker, the hex box, and the R/G/B boxes in sync — edit any of them and the rest update instantly. The HSL value (hue, saturation, lightness) is the same color in a form that's easier to tweak by eye: change the hue to rotate around the color wheel, or the lightness to make it lighter or darker.
The 3-digit shorthand
CSS lets you write a hex color with three digits when each pair repeats:#39f expands to #3399FF. It only works when both digits of every channel are equal, so most colors need the full six.
Worked example: #FF8800
Split it into pairs: FF, 88, 00. In decimal that's 255, 136, 0 — a strong orange, rgb(255, 136, 0). Here every pair happens to repeat its own digit (FF, 88, 00), so this color also has the shorthand#F80. A color like #3B82F6 doesn't: 3B, 82, and F6 each use two different digits, so it needs the full six.
Common questions
- What does a hex colour code actually mean?
- It is three numbers written in base 16, one each for red, green and blue.
#4A90D9splits into4A,90andD9— that is 74, 144 and 217 in decimal, so it is a medium blue. Each pair runs from00(none of that colour) toFF(255, the maximum), which is why two hex digits per channel gives the familiar 0–255 range. - What is the difference between #FFF and #FFFFFF?
- Nothing — they are the same colour. The three-digit form is shorthand in which each digit is doubled, so
#FFFexpands to#FFFFFFand#4A9expands to#44AA99. The shorthand can only express 4,096 colours rather than the full 16.7 million, so it works for round values like white, black and pure red, but most colours need all six digits. - Can I convert hex to RGB by hand?
- Yes, and it is worth being able to. Take each pair of digits and read it as base 16: the first digit is worth 16 each and the second 1 each. So
D9is (13 × 16) + 9 = 217, remembering that A–F stand for 10–15. Going the other way, divide by 16 for the first digit and take the remainder for the second. - Does hex work the same way in CSS, Photoshop and my phone?
- The notation is identical, but the colour you see may not be. A hex value is an instruction in the sRGB colour space, which is what browsers assume. Display it on a wide-gamut monitor with a different profile, or print it, and the appearance shifts even though the number has not. For matching a physical sample, treat the hex value as a starting point and confirm against the real thing.