New to Rust? Grab our free Rust for Beginners eBook Get it free →
Online HEX to RGB Converter: Convert Color Codes

Moving a color between a stylesheet and a design tool can mean changing how its value is written. An online HEX to RGB converter changes a hexadecimal color code into the decimal values used for its RGB channels.
You’ll see how to convert a HEX code and check which input formats the converter accepts.
TL;DR
Split a six-digit HEX code into red, green and blue pairs, then convert each base-16 pair to a decimal value from 0 to 255.
- Enter three or six hex digits, with or without #.
- For shorthand such as #4A3, repeat each digit to form #44AA33.
- Copy the resulting RGB triplet into CSS or a design tool.
What is HEX to RGB conversion?
HEX and RGB are two ways to express a color in the sRGB color space. A six-digit HEX color encodes red, green and blue as three hexadecimal pairs, while RGB writes those channel values as decimal numbers.
Hexadecimal is base 16, so each digit can be 0–9 or A–F. A pair contains two base-16 digits and represents one byte. Its range is 00 through FF, or 0 through 255 in decimal.
In #RRGGBB, the first pair RR sets red, GG sets green and BB sets blue. The code #ff6600 therefore becomes rgb(255, 102, 0): red is at its maximum, green is 102 and blue is zero.
A three-digit code such as #4A3 is shorthand for #44AA33. Each single digit is repeated to make its two-digit channel pair, so 4 becomes 44, A becomes AA and 3 becomes 33.
CSS also defines four- and eight-digit HEX forms that include alpha, the transparency channel. This converter does not accept those forms, so use only three or six hexadecimal digits here. MDN documents the broader CSS hex-color syntax and the rgb() function.
In hexadecimal notation, place value increases from right to left. The right digit counts ones, and the left digit counts groups of sixteen. That is why the pair 2F means two groups of sixteen plus fifteen, which equals 47 in decimal.
The same arithmetic works for every pair. For C4, C has decimal value 12, so the calculation is 12 multiplied by 16 plus 4, giving 196. For 09, the leading zero contributes no sixteens and the result is nine.
This positional rule helps when comparing nearby colors. Changing only the final digit changes a channel by one step, while changing the left digit changes it by sixteen steps. That distinction is useful when adjusting a shade by hand.
How to convert a HEX color to RGB
HEX to RGB conversion expresses the same color with a different notation. The converter does the arithmetic for each channel. Pair order tells you which decimal number belongs in each CSS position.
Step 1: Enter the HEX color
Paste the color into the HEX Input box above. You may include the leading #, omit it, or use the three-digit shorthand supported by this tool.
Step 2: Convert the value
Select Convert to RGB. The result appears in the read-only RGB Output box as a comma-separated CSS value.
Step 3: Copy the RGB triplet
Copy the result into a CSS declaration or a design tool that accepts RGB values. For example, rgb(255, 102, 0) can be used as a color value in CSS.
Step 4: Reset before another color
Select Clear All to empty both fields before converting another color. This avoids mistaking the previous output for the result of a new input.
You can also do the conversion by hand. Read each two-character pair as a base-16 number, then write its decimal value in the matching red, green or blue position.
| HEX pair | Channel | Decimal |
|---|---|---|
| FF | Red | 255 |
| 66 | Green | 102 |
| 00 | Blue | 0 |
For a pair XY, calculate 16 times the decimal value of X, then add the value of Y. In 66, both digits are six, so 6 × 16 + 6 equals 102. In FF, each F is 15, so 15 × 16 + 15 equals 255.
That gives #FF6600 as rgb(255, 102, 0). The ordering does not change between formats: red remains first, green second and blue third.
After copying a result, verify it at the point where it will be used. A CSS declaration accepts an RGB function value, while a design application may label the fields R, G and B. Match each decimal number to its named channel instead of copying the string into an unrelated field.
If the result looks unexpected, compare the original and converted forms channel by channel. A very high first number means strong red, not strong blue.
A low third number means little blue. This check can expose a swapped-pair mistake before it reaches a stylesheet.
Which HEX inputs does the converter accept?
The embedded converter accepts exactly three or six hexadecimal digits after an optional leading #. It expands shorthand, ignores letter case and reports an error for other lengths or non-hexadecimal characters.
| Input | What happens | Example |
|---|---|---|
| Leading # | Removed before parsing | #ff6600 |
| Uppercase letters | Accepted as hex digits | #FF6600 |
| Three digits | Each digit is duplicated | #4A3 becomes #44AA33 |
| Four or eight digits | Rejected by this tool | #F60A or #FF660080 |
| Invalid character or length | Displays an error | #GG6600 or #12345 |
CSS allows #RGBA and #RRGGBBAA, where the final digit or pair controls alpha. The tool’s validation checks only for three or six hexadecimal digits, so it will reject these otherwise valid CSS color forms. Convert the RGB portion separately if you need channel values, and preserve alpha in the format your project uses.
Whitespace around the input is trimmed. The leading # is optional, but other punctuation is not stripped. If an error appears, remove spaces inside the code and check that every remaining character is 0–9 or A–F.
Conversion changes notation, not the color’s channel meaning. If you need to reverse the direction, use the Online RGB to HEX Converter. For a different base conversion task, CodeForGeek also has an Online Hex to Decimal Converter.
Case does not change the value. For instance, #aBc and #ABC both expand to the same shorthand channels because A and a each represent decimal ten, while B represents eleven and C represents twelve.
When checking a hand calculation, convert each channel independently before assembling the final triplet. This catches a single mistyped pair without forcing you to redo the other two channels.
Common HEX to RGB conversion errors
Conversion errors usually come from an input the tool does not accept or from placing a valid channel in the wrong position. Check the digit count and preserve the red, green, blue order before using the result.
- Confirm the input contains three or six digits.
- Check that every character is a hexadecimal digit.
- Read output channels in red, green, blue order.
| Case | What you see | What to do |
|---|---|---|
| Four or eight digits | The converter rejects the code | Use a CSS-aware tool for alpha, or separate RGB from alpha deliberately |
| Non-hex character | An input error appears | Replace characters outside 0–9 and A–F |
| Digits in the wrong order | The output is a different color | Read the pairs as red, green, then blue |
| Shorthand read as three complete pairs | Channel values are wrong | Duplicate each digit before conversion |
Alpha is separate from the three color channels. For #RRGGBBAA, the final pair represents opacity, so copying all four pairs into an RGB triplet would shift the meaning of the color.
A useful check is a primary or neutral color with recognizable channels. The code #000000 maps to rgb(0, 0, 0), and #FFFFFF maps to rgb(255, 255, 255). For #FF0000, the green and blue positions stay at zero.
The decimal value is a channel intensity, not a percentage. Zero contributes none of that channel, and 255 is its maximum in the 8-bit notation used by standard CSS RGB numeric values. A value such as 128 is about halfway through that channel’s numeric range.
That range also gives you a quick validity check. Each output number should be an integer from 0 through 255 for this notation. A result outside that range points to a parsing mistake or a different color representation.
For example, #336699 has pairs 33, 66 and 99. Their decimal values are 51, 102 and 153, so the equivalent is rgb(51, 102, 153). Keeping the pairs aligned avoids swapping a cool blue channel into the red position.
Rounding is not part of this conversion. Every two-digit HEX pair maps exactly to an integer channel, so #808080 becomes rgb(128, 128, 128), not three approximate decimal fractions.
Do not confuse the numeric conversion with color appearance on a particular screen. The triplet identifies channel values in the relevant color notation, while display calibration and surrounding colors can affect what your eyes perceive.
When pasting a result into CSS, keep the function syntax and commas together. A declaration can use the returned value directly, as in a color declaration using rgb(51, 102, 153) inside a selector. If your codebase uses modern space-separated color syntax, follow that project’s style rather than changing the channel order.
For a channel pair with a letter, use its hexadecimal value rather than its alphabet position. A is ten, B is eleven, and the values continue through F as fifteen. Thus 7B is 7 multiplied by 16 plus 11, or 123.
Leading zeroes matter as notation even though they do not change the decimal answer. The pair 0A still has two places and converts to ten. Keeping the two-digit form visible makes the channel boundary clear when you split a six-digit code.
Conclusion: Match each HEX pair to an RGB channel
For a six-digit color, split HEX into red, green and blue pairs, then convert each pair from base 16 to decimal. The tool above accepts three- and six-digit inputs, including an optional #, and returns the RGB triplet.
Use MDN’s hex-color reference when checking CSS forms with alpha. Use the CodeForGeek RGB to HEX converter when you need the reverse conversion.
FAQ
These answers cover the accepted input forms and the channel conversion.
How do I convert HEX to RGB?
Split the six-digit HEX value into three pairs and convert each pair from base 16 to decimal. The pairs map to red, green and blue, in that order.
Can I enter a HEX code without #?
Yes. The converter accepts three or six hexadecimal digits with or without a leading #.
Does the converter accept eight-digit HEX?
No. Although CSS supports eight-digit HEX colors with alpha, this converter accepts only three or six digits.




