Convert hex color codes to RGB values and vice versa with a live color preview swatch.
Hex to RGB: Each pair of hex digits represents a color channel (red, green, blue) with values 0-255. #FF0000 = rgb(255, 0, 0) = pure red.
RGB to Hex: Convert each 0-255 value to a two-digit hexadecimal number. rgb(37, 99, 235) = #2563EB.
Colors on screens are created by combining red, green, and blue light -- the RGB color model. Each channel can have a value from 0 (none) to 255 (full intensity), giving a total of 256 x 256 x 256 = 16,777,216 possible colors. The hex color system is simply a more compact way to represent these same RGB values using hexadecimal (base-16) notation. Instead of writing rgb(255, 128, 0), you write #FF8000.
In hexadecimal, digits go from 0-9 and then A-F (where A=10, B=11, C=12, D=13, E=14, F=15). A two-digit hex number can represent values from 00 (0 in decimal) to FF (255 in decimal). A hex color code is six digits: the first two for red, the middle two for green, and the last two for blue. The # symbol is a convention indicating a hex color.
Hex codes are the standard in web development (CSS), graphic design, and digital media because they are compact and unambiguous. RGB values are more intuitive for understanding color composition and are used extensively in image editing software, LED programming, and color science. Both representations describe the exact same colors -- this converter helps you switch between them instantly.
Beyond RGB, there are other color models like HSL (hue, saturation, lightness) and HSV (hue, saturation, value). HSL is particularly useful for designers because adjusting lightness to make a color lighter or darker is more intuitive than modifying individual RGB channels. This converter also shows the HSL equivalent so you have all three representations at once.
| Color | Hex | RGB | Preview |
|---|---|---|---|
| Red | #FF0000 | 255, 0, 0 | |
| Green | #00FF00 | 0, 255, 0 | |
| Blue | #0000FF | 0, 0, 255 | |
| White | #FFFFFF | 255, 255, 255 | |
| Black | #000000 | 0, 0, 0 | |
| Coral | #FF6B6B | 255, 107, 107 |
A hex color code is a 6-digit hexadecimal number preceded by # that represents a color. The first two digits are red, middle two are green, last two are blue. Each pair ranges from 00 (0) to FF (255).
Split the hex code into three pairs. Convert each pair from hexadecimal to decimal. For example, #1A2B3C: 1A = 26 (red), 2B = 43 (green), 3C = 60 (blue) = rgb(26, 43, 60).
RGBA adds an alpha channel (A) for opacity/transparency. The alpha value ranges from 0 (fully transparent) to 1 (fully opaque). rgba(255, 0, 0, 0.5) is a semi-transparent red.
Yes. A 3-digit hex code is shorthand where each digit is doubled. #F00 = #FF0000, #09C = #0099CC. This only works when each pair has identical digits.