How the conversion works
A hex color is three bytes written in base 16: #RRGGBB. Each pair is one channel from 00 (0) to ff (255). For #3b82f6:
3b → 3×16 + 11 = 59 red
82 → 8×16 + 2 = 130 green
f6 → 15×16 + 6 = 246 blue
→ rgb(59 130 246)
Short hex doubles each digit: #abc = #aabbcc. Eight digits add alpha: in #3b82f680 the last pair 80 = 128 / 255 ≈ 50 % opacity, written in CSS as rgb(59 130 246 / 50%).
In code
// JavaScript
const hex = '3b82f6';
const [r, g, b] = [0, 2, 4].map(i => parseInt(hex.slice(i, i + 2), 16));
# Python
tuple(int('3b82f6'[i:i+2], 16) for i in (0, 2, 4)) Questions
rgb() or rgba()?
Both work in all current browsers. Modern CSS writes alpha inside rgb() with a slash: rgb(59 130 246 / 50%); rgba(59, 130, 246, 0.5) is the older, still valid form.
Can I convert RGB back to hex?
Yes – paste rgb(59, 130, 246) or any other CSS color into the same field; every format updates.
Is the color readable as text?
Check it in the WCAG contrast panel next to the formats, or open the contrast checker page.