Understanding the HEX to RGB converter — concept and principle
Web colours are often written as HEX codes like #1E90FF, while design tools and CSS functions use RGB numbers like rgb(30, 144, 255). This converter goes both ways, supports short forms and an alpha (opacity) channel, and also shows the colour as a single 24-bit decimal number.
How it is calculated
#RRGGBB: each pair of hex digits is one channel from 00 (0) to FF (255)
Pair value = first digit × 16 + second digit (A = 10 … F = 15)
Short forms double each digit: #0AF = #00AAFF
Optional fourth pair = alpha, from 00 (transparent) to FF (opaque), shown as 0–1
RGB → HEX: write each 0–255 value as two hex digits
24-bit number = R × 65,536 + G × 256 + B
The principle
Hexadecimal is base 16, so two hex digits can represent 16 × 16 = 256 values, exactly the range of one 8-bit colour channel. That makes HEX a compact way to write the three bytes of a colour. The same bytes can be read as one 24-bit number with red in the high byte and blue in the low byte, which is how many programs store colours internally.
Worked example
Default input: HEX → RGB, #1E90FF.
- 1E = 1 × 16 + 14 = 30 (red).
- 90 = 9 × 16 + 0 = 144 (green).
- FF = 15 × 16 + 15 = 255 (blue).
- Result 30, 144, 255; CSS rgb(30, 144, 255); alpha 1 (no alpha pair).
- 24-bit number = 30 × 65,536 + 144 × 256 + 255 = 2,003,199.
How to read the result
Use whichever notation your tool needs; the colour is identical. When you need transparency, use the eight-digit form #RRGGBBAA or rgba(). The same values may look different on different screens because of display calibration and colour profiles.
Common mistakes
- Swapping the order of channels (it is always red, green, blue).
- Reading the letter O as the digit 0 in a code.
- Forgetting that the alpha pair is 00–FF in HEX but 0–1 in rgba().
- Using a three-digit code where some older software expects six digits.
Frequently asked questions
What does #FFF mean?
It is short for #FFFFFF, pure white.
How do I add transparency?
Use #RRGGBBAA, or rgba(r, g, b, a) with a between 0 and 1.
Is HEX case-sensitive?
No. #1e90ff and #1E90FF are the same colour.
What colour is #1E90FF?
A bright blue, known in CSS as "dodgerblue".
Sources: W3C, CSS Color Module Level 4: hexadecimal notation and the rgb()/rgba() functions