home > real world > web resource > web utility programs >
RGB vs HEX
RGB stands for Red - Green - Blue.
Any of the Red-Green-Blue value is only between 0 - 255: 0 for the lowest content of that color, 255 for the highest content of the same color.
The format of an RGB color is: (I give you a random color) 128-34-246 (I don't know what color is this, but you can find it with the Color picker tool).
RGB can be from 0-0-0 (black) to 255-255-255 (white).
HEX is the same with RGB (red-green-blue), but in different format: each tent is 2 digits: 00, 2A, FF, etc.
HEX values are between 0 - 9 and A - F: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
So we increase the color from 00 (black) to FF (white) like: 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, and we start again with 1: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A ... 1F, and then 20, 21, 22 ... 2F and so on. And we finish with F1, F2, F3, F4, F5, F6, F7, F8, F9, FA, FB, FC, FD, FE, FF.
The format of an HEX color is: (for example) 8022F6 (this is the equivalent of the above RGB color, 128-34-246, but don't tell anyone). 80 stands for the Red value (equiv. 128 RGB), 22 for the Green value (34 RGB) and F6 for the Blue value (246 RGB).
How did I find the equivalence? Read further.
Converting RGB to HEX
Mind that HEX is 16 characters wide, and 16x16=256 (RGB, isn't it? - Attention! from 0 to 255 are 256 units, not 255; from 1 to 255 are 255 units - trust me, I know what I'm doing).
So the colors convert from RGB to HEX by 16. Thus, every 16 RGB makes a 10 HEX. 32 RGB = 20 HEX. 48 RGB = 30 HEX. And so on. Mind that the first integer is for the exact result, and the second is for the remaining.
Exercise: For example, if we want to know what HEX value is 128 RGB, we divide 128 by 16 and we find 8. So 16 is 8 times within 200; a 16 RGB is 10 HEX; by 8 it equals 80: so 128 RGB = 80 HEX.
Exercise: Now let's try to calculate another HEX value from an RGB one.
I take for instance the random value of 200 RGB.
First, we divide 200 by 16, and we find 12.5. More exactly, the result is 12 and remain 8.
Because 16 is 12 times within 200, the first HEX value will be C.
Now we have a remain of 8, which is the same on HEX, 8, so the second value will be 8.
So, finally, the 200 RGB will be C8 HEX.
If you don't believe it, try for yourself with the HEX-RGB converter tool.
For your comfort, I built the following Conversion chart.
Conversion chart
CONVERSION CHART |
0 - 15 RGB :: 0 HEX |
RGB |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
HEX |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
16 - 31 RGB :: 1 HEX |
RGB |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
HEX |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 1A | 1B | 1C | 1D | 1E | 1F |
32 - 47 RGB :: 2 HEX |
RGB |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
HEX |
20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 2A | 2B | 2C | 2D | 2E | 2F |
48 - 63 RGB :: 3 HEX |
RGB |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
HEX |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 3A | 3B | 3C | 3D | 3E | 3F |
64 - 79 RGB :: 4 HEX |
RGB |
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
HEX |
40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 4A | 4B | 4C | 4D | 4E | 4F |
80 - 95 RGB :: 5 HEX |
RGB |
80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |
HEX |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 5A | 5B | 5C | 5D | 5E | 5F |
96 - 111 RGB :: 6 HEX |
RGB |
96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 |
HEX |
60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 6A | 6B | 6C | 6D | 6E | 6F |
112 - 127 RGB :: 7 HEX |
RGB |
112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
HEX |
70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 7A | 7B | 7C | 7D | 7E | 7F |
128 - 143 RGB :: 8 HEX |
RGB |
128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 |
HEX |
80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 8A | 8B | 8C | 8D | 8E | 8F |
144 - 159 RGB :: 9 HEX |
RGB |
144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 |
HEX |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 9A | 9B | 9C | 9D | 9E | 9F |
160 - 175 RGB :: A HEX |
RGB |
160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 |
HEX |
A0 | A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | AA | AB | AC | AD | AE | AF |
176 - 191 RGB :: B HEX |
RGB |
176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 |
HEX |
B0 | B1 | B2 | B3 | B4 | B5 | B6 | B7 | B8 | B9 | BA | BB | BC | BD | BE | BF |
192 - 207 RGB :: C HEX |
RGB |
192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |
HEX |
C0 | C1 | C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | CA | CB | CC | CD | CE | CF |
208 - 223 RGB :: D HEX |
RGB |
208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 |
HEX |
D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9 | DA | DB | DC | DD | DE | DF |
224 - 239 RGB :: E HEX |
RGB |
224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 |
HEX |
E0 | E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9 | EA | EB | EC | ED | EE | EF |
240 - 255 RGB :: F HEX |
RGB |
240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 |
HEX |
F0 | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | FA | FB | FC | FD | FE | FF |
|