
You are deep in a design workflow. Your developer asks for the RGB values for the blue in your mock-up, but your design software only shows the HEX code. Or perhaps you are writing CSS and need to use an RGBa value for transparency, but your brand guide only provides HEX. This is a common crossroads for designers. HEX and RGB are simply two different languages for describing the exact same color. Understanding how to translate between them is a fundamental, practical skill.
This guide will show you exactly how to convert HEX codes to RGB values, both manually (to understand the math) and instantly using the tools you already have.
#4f3b80. It is compact and widely used in web design and CSS.rgb(79, 59, 128).#4f3b80andrgb(79, 59, 128)are identical.Before converting, it helps to know what you are working with.
RGB (Red, Green, Blue) is an additive color model. This means colors are created by adding together red, green, and blue light. Each channel has a value from 0 (none of that light) to 255 (the full amount of that light).
rgb(0, 0, 0)is black (no light).rgb(255, 255, 255)is white (all light).rgb(255, 0, 0)is pure red.HEX (Hexadecimal) is just a different way to write these same RGB values. Instead of using base-10 (decimal) numbers from 0-255, it uses base-16 (hexadecimal) numbers.
Here,A= 10,B= 11,C= 12,D= 13,E= 14, andF= 15. A two-digit hexadecimal number can represent16 x 16 = 256different values, perfectly matching the 0-255 range of RGB.
A HEX code is structured as:#RRGGBB
RR) represent the Red value.GG) represent the Green value.BB) represent the Blue value.Knowing how to do this manually demystifies the process. Let's convert the purple color#4f3b80to RGB.
Step 1: Break the HEX Code into Pairs Take the HEX code#4f3b80and break it into its three components:
4f3b80Step 2: Convert Each Pair from Base-16 to Base-10 Each digit in a pair represents a number. The first digit is the "16s" place, and the second digit is the "1s" place. The formula is:(First Digit × 16) + (Second Digit) = RGB Value
Let's apply this to each pair:
Red:4f
4(which is 4 in decimal)f(which is 15 in decimal)(4 × 16) + (15) = 64 + 15 = 79Green:3b
3(which is 3 in decimal)b(which is 11 in decimal)(3 × 16) + (11) = 48 + 11 = 59Blue:80
8(which is 8 in decimal)0(which is 0 in decimal)(8 × 16) + (0) = 128 + 0 = 128Step 3: Write the RGB Value: Combine the results into the standard RGB format:rgb(79, 59, 128)
No designer converts colors by hand all day. You have powerful tools to do this for you.
1. Using Your Design Software: All major design applications show both HEX and RGB values in their color pickers.
2. Using Online Converters: For a quick one-off conversion, online tools are fastest.
3. Using Browser Developer Tools: If you are inspecting a website, you can easily find and convert colors.
colororbackground-colorproperty in the "Styles" tab.
Understanding the conversion is useful, but knowing when to use each format is key.
Use HEX when:
Use RGB when:
rgba(79, 59, 128, 0.5)) allows you to set an opacity/alpha value, which is not possible with standard HEX.| HEX Code | RGB Value | Color | Swatch |
|---|---|---|---|
#ffffff |
rgb(255, 255, 255) |
White | |
#000000 |
rgb(0, 0, 0) |
Black | |
#ff0000 |
rgb(255, 0, 0) |
Red | |
#00ff00 |
rgb(0, 255, 0) |
Green | |
#0000ff |
rgb(0, 0, 255) |
Blue | |
#808080 |
rgb(128, 128, 128) |
Gray |
Converting HEX to RGB is not a mysterious art. It is a straightforward translation between two systems that do the same job. While knowing the manual process builds a deeper understanding of how digital color works, your everyday workflow will rely on the instant conversion tools built into your design software and browser. The real skill is knowing which format to use for the task at hand. Now, the next time a developer asks for an RGB value, you can provide it in seconds.
What about 3-digit HEX codes? A 3-digit HEX code like#f0ais a shorthand for its 6-digit equivalent. Each digit is doubled. So,#f0abecomes#ff00aa. You convert it to RGB the same way:ff(Red)=255,00(Green)=0,aa(Blue)=170. Result:rgb(255, 0, 170).
How do I convert RGB to HEX? You reverse the manual process. Take each RGB value and convert it from base-10 to a two-digit base-16 number.
79(Red from our example):79 ÷ 16 = 4.9375. The quotient is4.79 - (4 * 16) = 15.15in hex isF.79in hex is4F.Is there a difference in the color between HEX and RGB? None whatsoever.#4f3b80andrgb(79, 59, 128)are the exact same color. They are just different notations. The color displayed on your screen depends on your monitor's calibration, not on whether it was defined using HEX or RGB.