Hex to RGB Converter
Paste a hex color code to get its RGB values, or enter RGB values to get the hex code. The conversion happens instantly as you type, and you can copy either format with one click.
Hex → RGB
RGB → Hex
How Hex to RGB Conversion Works
A hex color code is just RGB written in base 16. The six characters after the # are three two-digit pairs: the first pair is the red channel, the second is green, and the third is blue. Each pair runs from 00 (0) to FF (255) — the letters A–F stand for the values 10–15.
To convert a pair by hand, multiply the first digit's value by 16 and add the second digit's value.
Worked Example: #2D6A4F
#2D6A4F
├─ 2D → (2 × 16) + 13 = 45 (red)
├─ 6A → (6 × 16) + 10 = 106 (green)
└─ 4F → (4 × 16) + 15 = 79 (blue)
Result: rgb(45, 106, 79)
Going the other way (RGB → hex), divide each value by 16: the quotient is the first hex digit and the remainder is the second. 45 ÷ 16 = 2 remainder 13, and 13 is D, so 45 becomes 2D.
Common Colors as Hex and RGB
| Color | Hex | RGB |
|---|---|---|
| Red | #FF0000 | rgb(255, 0, 0) |
| Green | #008000 | rgb(0, 128, 0) |
| Blue | #0000FF | rgb(0, 0, 255) |
| Orange | #FFA500 | rgb(255, 165, 0) |
| White | #FFFFFF | rgb(255, 255, 255) |
| Black | #000000 | rgb(0, 0, 0) |
Three-digit shorthand hex codes work too: each digit is doubled, so #fa3 means #ffaa33. The converter above accepts both forms.
Frequently Asked Questions
-
How do you convert hex to RGB?
Split the six-digit hex code into three pairs — the first pair is red, the second green, the third blue — then convert each pair from base 16 to decimal. Each result is a value from 0 to 255. For example,
#2D6A4Fbecomesrgb(45, 106, 79)because 2D = 45, 6A = 106, and 4F = 79. -
How do you convert RGB to hex?
Convert each of the three RGB values (0–255) to a two-digit base-16 number and join them in red, green, blue order behind a
#symbol. For example,rgb(45, 106, 79)becomes#2D6A4F. Values below 16 get a leading zero, sorgb(0, 128, 5)is#008005. -
Can I convert hex to RGB in CSS?
You rarely need to — CSS accepts hex and
rgb()notation interchangeably, and modern CSS lets you derive one from the other with relative color syntax likergb(from #2D6A4F r g b). Conversion mainly matters when a tool, API, or design spec requires one specific format. -
Can I convert hex or RGB to Pantone?
Only approximately. Pantone is a proprietary spot-color system for print, and its inks can fall outside the sRGB range that hex and RGB describe, so there is no exact formula. Tools (including Pantone's own) match a hex or RGB value to the closest Pantone swatch, but the printed ink may still differ from what you see on screen.
-
What do the letters in a hex color code mean?
Hex codes use base-16 digits, where the letters A–F stand for the values 10–15. Each two-character pair counts from
00(0) toFF(255), so letters simply extend the digits 0–9 to cover all 256 possible values per color channel.
Want to go beyond conversion? Start from your hex code on the HexTints homepage to build complete palettes, or read up on how tints and shades work.