HEX to RGB Converter
Convert HEX color codes to RGB values, with a live preview and HSL output too.
Split the code into three pairs
A 6-digit hex code is three 2-digit numbers in base 16: red, green, then blue. Multiply the first digit of each pair by 16 and add the second, counting a to f as 10 to 15. For #1e90ff:
| Pair | Calculation | Channel |
|---|---|---|
| 1e | 1 × 16 + 14 | Red 30 |
| 90 | 9 × 16 + 0 | Green 144 |
| ff | 15 × 16 + 15 | Blue 255 |
The converter shows this as rgb(30, 144, 255), with the HSL equivalent, hsl(210, 100%, 56%), next to it.
Codes the HEX box accepts
- With or without the
#:1e90ffworks the same as#1e90ff. - Upper or lower case:
#1E90FFgives the same result. - 3-digit shorthand, which is expanded by doubling each digit:
#f80becomes ff8800, which isrgb(255, 136, 0). - Spaces before or after the code, which the conversion ignores.
It rejects 4-digit and 8-digit codes with transparency (such as #4f46e580), colour names, a doubled ##, and typos like #12345g.
Don't copy the RGB while the code is invalid
Type a code the converter can't parse and the preview goes grey, with a hint under the boxes. The RGB and HSL fields don't go blank. They show the page's default indigo, rgb(79, 70, 229), whatever you typed. If you see that value and didn't expect it, check your code for a missing digit or an alpha pair before copying.
For code that needs three separate numbers rather than an rgb() string, read them from the R, G and B boxes below the result.
Frequently asked questions
What RGB value is #808080?+
rgb(128, 128, 128), a mid grey. Any code whose three pairs are equal, such as #333333 or #cccccc, is a shade of grey.
Is anything lost when converting hex to RGB?+
No. Each hex pair maps to exactly one whole number from 0 to 255, so converting back gives the same code. Only the HSL value next to it is rounded.
Can I convert a list of hex codes at once?+
No, the page works with one colour at a time. Paste each code into the HEX box in turn and copy the RGB value before moving on.
Why doesn't the preview swatch change even though the RGB value looks right?+
This happens when the pasted code has a space in front of it. The conversion ignores the space, but the preview can't read the code, so the swatch keeps showing the previous colour. Delete the space and the swatch updates.
Embed this tool on your website
Free to use on blogs, school sites and intranets. Paste this code into your page's HTML; please keep the credit line.
<iframe src="https://utilityapp.lat/embed/convert/hex-to-rgb" title="HEX to RGB Converter" width="100%" height="520" style="border:0;max-width:760px" loading="lazy"></iframe> <p style="font-size:13px"><a href="https://utilityapp.lat/convert/hex-to-rgb">HEX to RGB Converter</a> by UtilityApp</p>