Convert a hex color code to RGB
Type or paste a hex code like #1E90FF to get rgb(30, 144, 255), or type an RGB value to get the hex code. Short codes, transparency and HSL are covered, and the working is shown under the result.
- Hex
-- CSS rgb()
-- CSS hsl()
-- R, G, B
-
How to convert hex to RGB by hand
A six-digit hex code is three pairs of base 16 digits: red, green and blue. The digits run from 0 to 9 and then A to F, where A is 10 and F is 15. Multiply the first digit of a pair by 16 and add the second to get a value from 0 to 255.
Take #1E90FF. Red is 1E: 1 × 16 + 14 = 30. Green is 90: 9 × 16 + 0 = 144. Blue is FF: 15 × 16 + 15 = 255. So #1E90FF is rgb(30, 144, 255), a bright blue. The tool prints these steps under every result.
Going the other way, divide each RGB value by 16. The whole part is the first hex digit and the remainder is the second: 144 / 16 = 9 remainder 0, so 144 is 90. Values under 16 need a leading zero, so 5 is 05, not 5.
Short, long and transparent hex codes
CSS Color Module Level 4 allows hex codes of 3, 4, 6 or 8 digits, and the letters can be upper or lower case. A three-digit code doubles each digit, so #0F8 is #00FF88. Four and eight digits add an alpha channel at the end, where 00 is fully transparent and FF is fully opaque: #0000FFCC is blue at 80% opacity, rgb(0 0 255 / 80%) in modern CSS.
Alpha in hex has 256 steps, so most percentages do not land on an exact pair. 50% is 128 / 255 in this tool, written 80, which reads back as 0.502. The converter keeps three decimals for alpha.
The hsl() value gives the same color as hue, saturation and lightness, which is easier to adjust by hand: raise the last number for a lighter shade of the same color.
Questions
What is the RGB value of a hex color?
Split the hex code into three pairs and read each pair as a base 16 number from 0 to 255: the first is red, the second green, the third blue. #FF0000 is rgb(255, 0, 0), #000000 is black, rgb(0, 0, 0), and #FFFFFF is white, rgb(255, 255, 255).
How do I convert RGB to hex?
Type the three values into the RGB box, such as 30, 144, 255, and the hex code appears in the hex box: #1E90FF. Each value becomes two hex digits, with a leading zero for values under 16.
Is #FFF the same as #FFFFFF?
Yes. A three-digit hex code is shorthand where each digit is doubled, so #FFF is #FFFFFF (white) and #1A3 is #11AA33. Only colors whose pairs repeat a digit can be written the short way.
What do the last two digits of an 8-digit hex code mean?
They are the alpha channel, the opacity. 00 is fully transparent, FF is fully opaque and 80 is about half. #1E90FF80 is the same blue as #1E90FF at about 50% opacity, rgba(30, 144, 255, 0.502).
Are hex codes case sensitive?
No. #1e90ff and #1E90FF are the same color in CSS and in design tools. Tick Lowercase hex letters if your code style prefers lower case.
Is anything I enter sent or saved?
No. The conversion runs in JavaScript inside this tab. The page only remembers the lowercase option, in this browser. Page views are counted with Cloudflare Web Analytics, which does not see the colors you enter.