Hex to RGB Converter
Convert a hex color code into its RGB red, green, blue values.
A designer sends over #FF5733 and your code needs it as rgb(255, 87, 51) instead — a bright orange-red either way, just written in two different formats that mean exactly the same thing.
How the conversion actually works
A hex colour code splits into three pairs of characters after the #: red, green, then blue. Each pair is a base-16 number from 00 to FF, which is 0 to 255 in ordinary base-10. Take #FF5733: FF is 255, 57 is 87, and 33 is 51 — giving red 255, green 87, blue 51, a warm, saturated orange-red.
Each pair is independent, so you can read a hex code’s approximate colour just by eye once you know the pattern: values near FF mean that channel is maxed out, values near 00 mean it contributes almost nothing.
Worked examples
| Hex | Red | Green | Blue | Color |
|---|---|---|---|---|
| #FF5733 | 255 | 87 | 51 | Orange-red |
| #2E86AB | 46 | 134 | 171 | Teal blue |
| #FFFFFF | 255 | 255 | 255 | White |
| #000000 | 0 | 0 | 0 | Black |
| #00FF00 | 0 | 255 | 0 | Pure green |
Converting hex to RGB
- Paste the hex code, with or without the leading
#. - The tool splits it into red, green and blue pairs automatically.
- Read off the three 0–255 values, or copy the ready-made
rgb()CSS string. - For a code with alpha transparency, an 8-digit hex, check the fourth pair separately — it maps to opacity, not a colour channel.
The 3-digit shorthand people forget how to expand
CSS also accepts a 3-digit shorthand, like #FFF, where each character is silently doubled to make the full 6-digit code — #FFF expands to #FFFFFF, not #FF0FF0 or anything else. It only works when both characters in each pair would be identical, which is why #FF5733 has no shorthand form but a pure colour like #0F0 (expanding to #00FF00) does.
Hex to RGB questions
What do the three pairs in a hex code represent?
The first two characters are red, the middle two are green, and the last two are blue, each running from 00 (none) to FF (full intensity) in base-16, equivalent to 0 to 255 in ordinary decimal.
How does the 3-digit hex shorthand expand?
Each character is doubled: #FFF becomes #FFFFFF and #0A3 becomes #00AA33. It only exists for colours where both digits of each pair would already match.
Is #ff5733 the same color as #FF5733?
Yes, hex codes are not case-sensitive. Upper and lowercase letters represent the same base-16 digits, so the two write identically to the same colour.
What is the RGB equivalent of pure white and pure black?
White is rgb(255, 255, 255), every channel maxed out. Black is rgb(0, 0, 0), every channel at zero. Equal values across all three channels always produce a shade of grey between them.
Can I convert an 8-digit hex code with transparency?
Yes — the first six digits convert to RGB exactly as normal, and the extra two digits at the end represent the alpha channel, which maps to an opacity percentage rather than a colour.