Hex to RGB Converter
How Computers See Color
Your computer screen creates millions of colors by mixing just three lights: Red, Green, and Blue (RGB). By varying the intensity of these three lights, you can create any color in the visible spectrum.
- R = Red Intensity (0 - 255)
- G = Green Intensity (0 - 255)
- B = Blue Intensity (0 - 255)
If all three are set to 0, the screen is black. If all three are set to 255, the screen is white.
What is a Hex Code?
RGB values (like `rgb(255, 87, 51)`) are easy for humans to understand, but they take up a lot of space in code. To make it more compact, web developers use Hexadecimal.
Hex is a Base-16 counting system. It counts 0-9, then A-F.
- 00 is the lowest value (0).
- FF is the highest value (255).
A Hex code is just three pairs of digits representing RGB:
So, #FF0000 means: Max Red (FF), Zero Green (00), Zero Blue (00). This creates bright red.
The Math: How to Convert Manually
If you were stranded on an island with no calculator, how would you convert Hex to RGB?
Take the code #2A (Red channel). In Hexadecimal:
- First Digit (2) = 2 × 16 = 32
- Second Digit (A) = 10 × 1 = 10
- Total = 32 + 10 = 42
So, #2A in Hex equals 42 in RGB.
Common Web Colors
Here is a cheat sheet for the standard HTML primary colors.
| Color Name | Hex Code | RGB Code |
|---|---|---|
| Black | #000000 | (0, 0, 0) |
| White | #FFFFFF | (255, 255, 255) |
| Red | #FF0000 | (255, 0, 0) |
| Green | #00FF00 | (0, 255, 0) |
| Blue | #0000FF | (0, 0, 255) |
| Gray | #808080 | (128, 128, 128) |