HEX to RGB Converter (and RGB to HEX, HSL)
Choose the direction and enter a colour.
Your numbers
Your results
HEX
HEX
—
RGB
—
HSL
—
Relative luminance (WCAG)
—
HEX to RGB Converter (and RGB to HEX, HSL) by TheCalcTools
How the HEX to RGB Converter (and RGB to HEX, HSL) works
A HEX colour is three pairs of hexadecimal digits for red, green and blue, each from 00 to FF (0 to 255). 1E90FF is red 30, green 144, blue 255.
HSL describes the same colour by hue (0 to 360°), saturation and lightness, which is easier for making lighter or darker variants in CSS.
The formula
RGB = (⌊n ÷ 65536⌋, ⌊n ÷ 256⌋ mod 256, n mod 256)
Worked example
Using the default values shown in the calculator:
| Convert | HEX to RGB and HSL |
|---|---|
| HEX colour (6 digits, # optional) | #1E90FF |
| Red (0 to 255) | 30 |
| Green (0 to 255) | 144 |
| Blue (0 to 255) | 255 |
- #1E90FF is rgb(30, 144, 255), hsl(210, 100%, 56%).
Result:
| HEX | #1E90FF |
|---|---|
| RGB | rgb(30, 144, 255) |
| HSL | hsl(210, 100%, 56%) |
| Relative luminance (WCAG) | 0.2744 |
Frequently asked questions
What about 3-digit HEX codes?
Expand each digit: #1AF is #11AAFF.
Sources and further reading
Related calculators
More in AI & Computing · All calculators
This calculator gives estimates for information only. Check important results independently before you rely on them. See our disclaimer.
