RGB ↔ Hex Color Converter
Convert red, green and blue values from 0 to 255 into a six-digit hex color code, or a hex code back to RGB, with a worked #1A2B3C example.
Results
Hex
- RGB
- rgb(26, 43, 60)
You might also need
Educational estimates · not financial advice · free, no signup
Formula / how it works
Hex = #RRGGBB, where each pair is the channel value in base 16. Channel value = 16 × first hex digit + second hex digit. Shorthand #RGB doubles each digit, so #F80 = #FF8800.
Detailed guide
What it is, how to use it, how to read the numbers, common mistakes, a worked example, formulas, and FAQs.
What this calculator is
Screen colors are made by mixing red, green and blue light, each with a strength from 0 to 255. Web designers write the same color in hexadecimal as a hash followed by three pairs of digits, one pair per channel. This tool converts in both directions. For a conversion from RGB, each channel is turned into two hex digits. For the reverse, each pair is converted back into a number from 0 to 255. Accessibility checks, such as contrast ratios, need the underlying channel values, so being able to move between the two formats is useful. The tool handles opaque colors only, with no alpha channel.
When to use / who it helps
- You are copying a color from a design tool into CSS.
- You have a hex code and need RGB values for another program.
- You are checking a color's channel values.
- You are building a palette.
- You are working on accessibility or contrast.
How to use
Steps
- Choose RGB to hex, or hex to RGB.
- Enter red, green and blue between 0 and 255, or a hex code.
- Read the converted value.
- Copy the result.
- Check each channel is within the range.
- Use six-digit hex for exact matches.
How to interpret results
- 255 is the maximum intensity of a channel.
- #000000 is black and #FFFFFF is white.
- Equal channels give grey.
- Shorthand hex doubles each digit.
- The hex digits for 255 are FF.
Common mistakes & gotchas
- Entering a channel above 255.
- Forgetting the leading zero, such as 5 instead of 05.
- Mixing up the order of the channels.
- Using three-digit shorthand for an exact color.
- Expecting alpha transparency in the output.
Worked example
Worked example — rgb(26, 43, 60)
- Red 26 = 1 × 16 + 10, so the hex pair is 1A.
- Green 43 = 2 × 16 + 11, so the hex pair is 2B.
- Blue 60 = 3 × 16 + 12, so the hex pair is 3C.
- Combined: #1A2B3C. In reverse, #FF8800 is rgb(255, 136, 0), since 88 hex is 136.
Result: rgb(26, 43, 60) is #1A2B3C.
To load the form's own demo values, tap Try example above the Calculate button.
How to calculate / formula
Hex = #RRGGBB, where each pair is the channel value in base 16. Channel value = 16 × first hex digit + second hex digit. Shorthand #RGB doubles each digit, so #F80 = #FF8800.
Frequently asked questions
How do I convert RGB to hex?
Convert each channel to a two-digit hex number and join them after a hash.
What is the range of each channel?
0 to 255.
What does #FFFFFF mean?
White: all three channels at maximum.
What is shorthand hex?
A three-digit form where each digit is doubled, such as #F80 for #FF8800.
Does the tool support transparency?
No, only opaque colors.
Why is hex used?
It is a compact way to write RGB values in CSS and design tools.