HEX to RGB Converter
Convert any hex color code to RGB values instantly, with the formula, a live swatch and copy-ready CSS.
The formula
Split the six hex digits into three pairs (RR GG BB) and convert each pair from base 16 to base 10. #3B82F6 → 3B = 3×16+11 = 59, 82 = 8×16+2 = 130, F6 = 15×16+6 = 246 → rgb(59, 130, 246). Three-digit shorthand doubles each digit: #0AF = #00AAFF.
Common colors
| Color | HEX | RGB | HSL | OKLCH |
|---|---|---|---|---|
| #000000 | rgb(0, 0, 0) | hsl(0 0% 0%) | oklch(0% 0 0) | |
| #FFFFFF | rgb(255, 255, 255) | hsl(0 0% 100%) | oklch(100% 0 0) | |
| #FF0000 | rgb(255, 0, 0) | hsl(0 100% 50%) | oklch(62.8% 0.258 29.2) | |
| #00FF00 | rgb(0, 255, 0) | hsl(120 100% 50%) | oklch(86.6% 0.295 142.5) | |
| #0000FF | rgb(0, 0, 255) | hsl(240 100% 50%) | oklch(45.2% 0.313 264.1) | |
| #FFFF00 | rgb(255, 255, 0) | hsl(60 100% 50%) | oklch(96.8% 0.211 109.8) | |
| #00FFFF | rgb(0, 255, 255) | hsl(180 100% 50%) | oklch(90.5% 0.155 194.8) | |
| #FF00FF | rgb(255, 0, 255) | hsl(300 100% 50%) | oklch(70.2% 0.322 328.4) | |
| #808080 | rgb(128, 128, 128) | hsl(0 0% 50%) | oklch(60% 0 0) | |
| #FFA500 | rgb(255, 165, 0) | hsl(39 100% 50%) | oklch(79.3% 0.171 70.7) | |
| #800080 | rgb(128, 0, 128) | hsl(300 100% 25%) | oklch(42.1% 0.193 328.4) | |
| #008080 | rgb(0, 128, 128) | hsl(180 100% 25%) | oklch(54.3% 0.093 194.8) |
Frequently asked questions
How do I convert hex to RGB?
Split the hex code into three two-digit pairs and convert each from hexadecimal to decimal. Each result is a channel from 0 to 255.
What does an 8-digit hex code mean?
The last two digits are alpha (opacity). #3B82F680 is the same blue at 128/255 ≈ 50% opacity, rgba(59, 130, 246, 0.5).
More converters: RGB to HEX · HEX to RGBA · HEX to HSL · HSL to HEX · RGB to HSL · HEX to OKLCH · All formats at once