The math, in one line
Each RGB channel runs 0 to 255, which is exactly what two hex digits can hold (00 to FF). Convert each channel to base 16, pad to two digits, concatenate. 59, 130, 246 becomes 3B, 82, F6, so #3B82F6.
Common values
| RGB | HEX | Color |
|---|---|---|
| 255, 255, 255 | #FFFFFF | White |
| 0, 0, 0 | #000000 | Black |
| 255, 0, 0 | #FF0000 | Red |
| 0, 255, 0 | #00FF00 | Green |
| 0, 0, 255 | #0000FF | Blue |
| 100, 116, 139 | #64748B | Slate |
| 24, 119, 242 | #1877F2 | Facebook blue |
Which notation to ship
Hex is compact and dominant in design tools and brand guidelines, so it travels well between designers and developers. CSS rgb() is easier to compute with and needed for alpha. Pick one per codebase and stay consistent; the converter above outputs both so a handoff never blocks on notation.
Print work needs CMYK
Neither hex nor RGB survives contact with a press unchanged. Ink gamut is smaller than screen gamut, and accurate conversion needs an ICC profile rather than a formula. Use the RGB to CMYK converter before sending brand colors to a printer.
