Convert HEX to RGB color codes
A HEX to RGB converter takes a web color code like #0F766E and splits it into the three numbers a screen actually uses: red, green and blue intensity from 0 to 255. You need the RGB form whenever an API, shader, spreadsheet or design tool asks for separate channel values instead of a hex string.
How a hex color code maps to RGB
A six-digit hex code is three two-digit hexadecimal numbers in a row: #RRGGBB. Each pair is one byte, so it ranges from 00 (0) to FF (255). To convert a pair, multiply the first digit by 16 and add the second, where the letters A–F stand for 10–15.
#0F766E
0F → 0 × 16 + 15 = 15 (red)
76 → 7 × 16 + 6 = 118 (green)
6E → 6 × 16 + 14 = 110 (blue)
→ rgb(15, 118, 110)
A second example: #1E90FF (the CSS color dodgerblue) gives 1E = 30, 90 = 144 and FF = 255, so rgb(30, 144, 255). The hex to decimal converter uses the same place-value method for numbers of any size if you want more practice with base 16.
Shorthand and other accepted inputs
- Three-digit shorthand.
#abcmeans#aabbcc: every digit is doubled, not padded with a zero. So#abcisrgb(170, 187, 204)and#fffis white,rgb(255, 255, 255). - With or without the hash.
0F766E,#0f766eand0x0F766Eare read the same way, and letter case doesn't matter. - CSS color names. Names such as
tomatoorrebeccapurpleare recognized and converted from their standard hex values. - Eight- and four-digit hex.
#RRGGBBAAand#RGBAcarry an alpha (opacity) byte. RGB has no slot for it, so the alpha is simply left out; the color channels are not blended with any background. Use HEX to RGBA when you need to keep the transparency.
Five- or seven-digit codes are not valid colors. They produce an error that quotes the offending value, so a typo can't slip through as a wrong color.
Where RGB values are needed
CSS accepts both notations, so on the web the choice is mostly style. RGB becomes necessary elsewhere: the Canvas API stores pixel data as 0–255 channel bytes, many charting and game libraries take three integers, and spreadsheets often keep colors as separate columns. Shader code and some engines expect 0–1 floats instead; divide each value by 255 (118 ÷ 255 ≈ 0.463).
Common mistakes
- Wrong byte order. Web hex is always red, green, blue (then alpha). Android and XAML put alpha first (
#AARRGGBB), so an eight-digit code copied from those platforms means something else in CSS. - Zero-padding shorthand.
#abcis not#0a0b0c. - Look-alike characters. Only 0–9 and A–F are valid; the letter O is a frequent typo for zero.
Going the other way? The RGB to HEX converter reverses the process. The conversion runs entirely in your browser, so the colors you enter are never uploaded.