HEX to RGB Converter
HEX input
- HEX
- #167d8d
- RGB
- rgb(22, 125, 141)
- HSL
- hsl(188.067, 73.006%, 31.961%)
What a HEX code actually stores
A six-digit HEX code is three pairs of hexadecimal digits, one pair each for red, green and blue. Each pair covers 0 to 255 in base 16, so "ff" is 255 and "00" is zero. The code "#167d8d" is therefore red 22, green 125, blue 141.
Three-digit shorthand repeats each digit: "#abc" expands to "#aabbcc". The shorthand cannot express every color, only the 4,096 values whose channel pairs both use the same digit. This converter expands shorthand before converting, so both forms produce the same RGB result.
Reading the RGB result
RGB describes a color as additive light: all three channels at 255 produce white, all three at zero produce black, and equal values produce a neutral gray. CSS accepts the same values as "rgb(22, 125, 141)".
Converting between HEX and RGB is exact in both directions because the two notations describe identical sRGB values. Nothing is approximated, and converting back returns the code you started with.
Opacity is out of scope
This converter handles opaque colors only. Eight-digit HEX codes carrying an alpha channel, the "transparent" keyword and named CSS colors are rejected rather than silently reinterpreted, because discarding an alpha value would change the color you see on a page.
Frequently asked questions
No. HEX and RGB are two notations for the same sRGB values, so the conversion is exact in both directions and round-trips without drift.