HEX to RGB Converter
Enter a hex code such as #FF6347 to get rgb(255, 99, 71), plus its HSL, OKLCH and CMYK equivalents.
How to convert HEX to RGB with this tool
- Paste a hex code into the input, with or without the leading
#. - Read the RGB / RGBA card, which updates on every keystroke.
#FF6347showsrgb(255, 99, 71). - Press Copy on that card to take the value exactly as written.
- Try a shorthand code such as
#F60to see it expanded to six digits and converted.
How to convert HEX to RGB by hand
A six-digit hex code is three pairs: red, green and blue. Each pair is a base-16 number from 00 to FF, which is 0 to 255 in decimal. To convert a pair, multiply the first digit by 16 and add the second, counting A as 10, B as 11, C as 12, D as 13, E as 14 and F as 15.
Worked example with #FF6347, the CSS color tomato:
- Red:
FF= 15 × 16 + 15 = 255 - Green:
63= 6 × 16 + 3 = 99 - Blue:
47= 4 × 16 + 7 = 71
The result is rgb(255, 99, 71). The first digit of each pair gives a quick read of channel strength: red is maxed out while green and blue sit low, so the color is a warm orange-red. More on the notation itself is in what a hex color is.
Shorthand and 8-digit hex codes
A 3-digit code repeats each digit, so #F60 expands to #FF6600, which is rgb(255, 102, 0). A 4-digit code follows the same rule with an alpha digit on the end: #F608 expands to #FF660088.
An 8-digit code puts an alpha pair after blue. Convert it like any other pair, then divide by 255 to get a 0–1 opacity. 80 is 128, and 128 ÷ 255 ≈ 0.502, so #FF634780 is tomato at roughly half opacity.
From 8-digit hex to rgba()
In CSS, that alpha becomes the fourth argument: #FF634780 is written rgba(255, 99, 71, 0.5) once 0.502 is rounded to two decimals. The two forms look the same on screen. rgba() is easier to read and adjust by hand, while 8-digit hex keeps tokens short. Current CSS also accepts the space-separated form rgb(255 99 71 / 50%).
If you need to know whether text on a translucent overlay is readable, test the blended color that actually appears on screen in the contrast checker, not the transparent value.
Frequently asked questions
How do I convert HEX to RGB?
Split the six digits into three pairs and convert each from base 16 to decimal by multiplying the first digit by 16 and adding the second. For #FF6347 that gives 255, 99 and 71, so rgb(255, 99, 71).
What is #FFFFFF in RGB?
#FFFFFF is rgb(255, 255, 255), which is white. Its opposite, #000000, is rgb(0, 0, 0), black.
How do I convert a 3-digit hex code to RGB?
Double each digit first, so #F60 becomes #FF6600, then convert the pairs as usual. The result is rgb(255, 102, 0).
How do I convert 8-digit hex with alpha to RGBA?
Convert the first three pairs to 0–255, then divide the last pair's decimal value by 255 to get alpha. #FF634780 becomes rgba(255, 99, 71, 0.5), because 80 in hex is 128 and 128 divided by 255 is about 0.502.
Is HEX or RGB better for CSS?
Neither is more accurate, since both describe the same sRGB colors. HEX is shorter for solid colors, while rgb() is easier to read when you want to adjust one channel or add transparency.
How many colors can a hex code represent?
A 6-digit hex code allows 256 values for each of three channels, which is 16,777,216 colors in total.