Hex to RGB Converter
The same colour in every notation you need.
Hex to RGB Converter
Convert a hex colour to RGB and HSL, with the equivalent values in every notation a stylesheet needs.
Accepts #abc, #aabbcc, or rgb(26, 43, 60).
- HEX
- #1a2b3c
- RGB
- rgb(26, 43, 60)
- HSL
- hsl(210, 40%, 17%)
Channels: R 26 · G 43 · B 60
Hue 210° · saturation 40% · lightness 17%
Embed this calculator
Put this calculator on your own site with the snippet below. The frame contains the tool only, reports its own height, and carries a visible link back to the full page. Embedding is free; keep the attribution link as it is, and do not wrap the frame in a way that hides it.
Preparing the embed code for this page...
What This Calculator Does
The Hex to RGB Converter translates a colour between hex, RGB, and HSL, with a live swatch so you can confirm the value looks right. It accepts three- and six-digit hex, with or without the leading hash, and rgb() notation.
How It Works
A six-digit hex code is three pairs of hexadecimal digits, one per channel. Each pair converts to 0–255. HSL is derived from those channels: hue from the largest channel, saturation from the spread between channels, and lightness from the midpoint of the largest and smallest.
Example
The colour #1a2b3c is rgb(26, 43, 60). Its hue is about 210°, saturation 40%, and lightness 17%. A three-digit code expands by duplication, so #f00 becomes #ff0000, or rgb(255, 0, 0).
Formula
Channel = parseInt(pair, 16)L = (max + min) / 2S = (max − min) / (1 − |2L − 1|)Reading the Results
HEX
The canonical six-digit form. Three-digit shorthand is expanded by duplicating each digit.
HSL
Hue is the colour angle in degrees, saturation and lightness are percentages. HSL is easier to adjust by hand than RGB because the three levers are perceptual.
Sources and References
W3C — CSS Color Module Level 4
Hex notation, rgb(), and hsl()
Defines the sRGB colour space and the syntax for each notation this tool supports.
IEC 61966-2-1 — sRGB colour space
Standard RGB gamut for displays
sRGB is the default colour space assumed by CSS colours on the web.
References identify the method or data behind this calculator. Where a standard or tariff changes, the current edition applies, and the assumptions stated above take precedence over a remembered figure.
Frequently Asked Questions
How do I convert hex to RGB by hand?
Split the six digits into three pairs. Convert each pair from base 16, so FF is 255 and 1A is 26. The three results are the red, green, and blue channels in that order.
Why do my converted colours look slightly different?
Hex and RGB are the same values, so they cannot differ. HSL is a mathematical transformation that can shift slightly with rounding, and different colour profiles can display the same sRGB value differently.
Does this support alpha transparency?
It handles solid colours in hex, rgb(), and hsl(). Eight-digit hex and rgba() alpha values are not converted, because the result would need a fourth channel with no single agreed notation.
Is hex the same as RGB?
Yes, in different notation. #1a2b3c and rgb(26, 43, 60) describe identical sRGB channels; hex is simply the same three bytes written in base 16.
