How HEX to RGB conversion works
A HEX code is not a different colour model at all: it is the same three RGB channels written in base 16. Each pair of digits is one channel, and each pair can hold 16 × 16 = 256 values, which is why RGB channels run from 0 to 255. Converting is just reading each pair as a number.
- Drop the
#and expand shorthand:#1E9becomes#11EE99(each digit doubled). - Split into three pairs: red, green, blue.
- For each pair, value = (first digit × 16) + second digit, where A = 10, B = 11 … F = 15.
- Write the result as
rgb(R, G, B).
Worked example: #1E90FF to RGB
Here is the converter's own calculation for #1E90FF, step by step. The result, rgb(30, 144, 255), is exactly what the tool above shows for this input.
- Split into pairs: 1E, 90, FF.
- Red: 1E = 1 × 16 + 14 = 30.
- Green: 90 = 9 × 16 + 0 = 144.
- Blue: FF = 15 × 16 + 15 = 255.
- Written as
rgb(30, 144, 255).
CSS named colours in HEX and RGB
Sixteen of the 148 named colours defined in CSS, with the HEX code the specification assigns to each.
| Colour | HEX | RGB |
|---|---|---|
| dodgerblue | #1E90FF | rgb(30, 144, 255) |
| tomato | #FF6347 | rgb(255, 99, 71) |
| rebeccapurple | #663399 | rgb(102, 51, 153) |
| steelblue | #4682B4 | rgb(70, 130, 180) |
| coral | #FF7F50 | rgb(255, 127, 80) |
| gold | #FFD700 | rgb(255, 215, 0) |
| seagreen | #2E8B57 | rgb(46, 139, 87) |
| slategray | #708090 | rgb(112, 128, 144) |
| crimson | #DC143C | rgb(220, 20, 60) |
| teal | #008080 | rgb(0, 128, 128) |
| orchid | #DA70D6 | rgb(218, 112, 214) |
| darkorange | #FF8C00 | rgb(255, 140, 0) |
| navy | #000080 | rgb(0, 0, 128) |
| lavender | #E6E6FA | rgb(230, 230, 250) |
| chocolate | #D2691E | rgb(210, 105, 30) |
| turquoise | #40E0D0 | rgb(64, 224, 208) |
Source: W3C CSS Color Module Level 4
Precision test: every HEX value through the converter
HEX to RGB is the one conversion on this site that can never lose anything: we ran all 16,777,216 HEX codes through the converter and back, and 100% returned identical. The two notations hold exactly the same information, so pick whichever the destination expects.
Method: every whole-number HEX value, through the converter's own code and back, compared on the 0–255 scale (how we test).
| Measure | Result |
|---|---|
| HEX values tested | 16,777,216 |
| Distinct RGB results | 16,777,216 |
| Came back exactly | 100% |
| Largest change (0–255 levels) | 0 |
| Average change | 0 |
Last updated · Source: Pixohub exhaustive test of lib/color-math.ts
Where you'll use HEX to RGB
Canvas and JavaScript drawing
Canvas getImageData() returns raw 0–255 channel values, and libraries such as Three.js or p5.js often take separate red, green and blue numbers. Converting the HEX from a style guide gives you those numbers directly.
Adding transparency in CSS
Designers hand over #1E90FF; for a 40% overlay you need rgb(30 144 255 / 0.4). You can also write the alpha in HEX as an eighth and ninth digit (#1E90FF66), but the rgb() form is easier to read and edit.
Hardware and LED projects
Arduino, WLED and smart-bulb APIs usually take three 8-bit integers. The HEX value from a colour picker maps one-to-one onto those, with no rounding.
Common mistakes
- Treating a 3-digit code as padded rather than doubled:
#F80is#FF8800, not#F80000. - Reading an 8-digit code as RGB: in
#1E90FF80the last pair is alpha (128 ≈ 50% opacity), not part of the colour. - Assuming RGB numbers are percentages:
rgb(30, 144, 255)uses 0–255. CSS also acceptsrgb(12% 56% 100%), which is a different scale for the same colour. - Mixing up channel order from code that stores colours as BGR (Windows GDI's
COLORREFand OpenCV both do); the numbers are right but red and blue swap.