Home › Developer Tools › RGB to HEX Converter
RGB to HEX Converter
Web colors come in two notations for the same thing: RGB (three numbers, 0-255, for red, green and blue) and HEX (a # followed by six hexadecimal digits). Move the sliders or type a hex code and this converter shows both, plus the HSL and CMYK equivalents, the closest CSS color name, and whether white or black text reads better on it.
HEX codes are case-insensitive: #ff7f50 is the same color as #FF7F50. The 3-digit shorthand doubles each digit, so #F80 means #FF8800. Contrast ratios follow the WCAG formula; 4.5:1 or higher is the recommended minimum for normal body text.
How it works
RGB and HEX describe the same color in different notations. RGB gives the red, green and blue channels as decimals from 0 to 255; HEX writes the same three numbers in hexadecimal (base 16), two digits per channel, after a #. Converting is just a base change: 255 in decimal is FF in hex (15×16 + 15), 127 is 7F, and 80 is 50. HSL re-describes the color as hue (an angle on the color wheel, 0-360°), saturation and lightness — often easier when you want a lighter or darker version of the same color. CMYK is the print equivalent: how much cyan, magenta, yellow and black ink the color needs. Worked example: rgb(255, 127, 80) = #FF7F50, the CSS color Coral; HSL 16°, 100%, 66%; CMYK 0% / 50% / 69% / 0%; contrast 2.50:1 with white text and 8.40:1 with black text, so black text reads far better on it. Worked example 2: #4169E1 (Royal Blue) = rgb(65, 105, 225); the 3-digit shorthand #F80 expands to #FF8800, rgb(255, 136, 0).
Frequently asked questions
What is a HEX color code?
A six-digit hexadecimal number after a #, with two digits per channel: #RRGGBB. #FF0000 is pure red (255 red, 0 green, 0 blue), #00FF00 is pure green, and #000000 is black. It is the standard way colors are written in CSS and design tools.
What does the 3-digit HEX shorthand mean?
Each digit is doubled: #F80 is #FF8800, and #FFF is #FFFFFF (white). It only works when each channel's two digits are identical, which is why most colors still need all six digits.
Is RGB the same as HEX?
Yes — same color, different notation. RGB(255, 127, 80) and #FF7F50 are identical; one is decimal, the other hexadecimal. Converting between them never changes the color, it only rewrites the numbers.
What is HSL, and when is it more useful?
HSL splits a color into hue (where it sits on the color wheel), saturation (how vivid it is) and lightness (how bright). It is easier than RGB for picking a lighter shade of the same color: keep the hue, raise the lightness. HSL(16, 100%, 66%) is the same color as #FF7F50.
What contrast ratio do I need for readable text?
The WCAG accessibility standard asks for at least 4.5:1 between text and background for normal body text (3:1 for large headings). This tool computes both ratios, so you can check whether white or black text is the readable choice on any background.