Learn how HEX and RGB color codes work and how to convert between them. Covers the RGB model, hex notation, alpha transparency, HSL colors, and CSS color formats.
Web colors are expressed in several formats — HEX, RGB, HSL, and HSB — and each serves a different purpose. HEX codes are compact and copy-pasteable; RGB values are intuitive for mixing; HSL maps to how humans perceive color. Knowing how to convert between them makes you a more effective designer and developer.
Digital screens produce color by mixing Red, Green, and Blue (RGB). Each channel ranges from 0 to 255. The format is rgb(red, green, blue).
rgb(255, 0, 0) = pure redrgb(0, 255, 0) = pure greenrgb(0, 0, 255) = pure bluergb(255, 255, 255) = whitergb(0, 0, 0) = blackA HEX color code is the RGB values written in hexadecimal: #RRGGBB. Each pair represents one channel (00–FF = 0–255 in decimal).
Convert each two-character HEX pair from base-16 to base-10:
#FF5733: FF=255, 57=87, 33=51 → rgb(255, 87, 51)#1A2B3C: 1A=26, 2B=43, 3C=60 → rgb(26, 43, 60)Convert each decimal channel to a two-digit hex string:
rgb(200, 100, 50): 200=C8, 100=64, 50=32 → #C86432rgb(0, 128, 255): 0=00, 128=80, 255=FF → #0080FFWhen each pair uses the same digit twice, a 3-character form works: #FFF = #FFFFFF, #000 = #000000, #F00 = #FF0000.
rgba(255, 0, 0, 0.5) = 50% transparent red#FF000080 = 8-digit HEX (80 hex ≈ 50% opacity)HSL is useful for generating color palettes: keep hue constant, vary lightness and saturation for harmonious shades.
| Color | HEX | RGB |
|---|---|---|
| Black | #000000 | rgb(0,0,0) |
| White | #FFFFFF | rgb(255,255,255) |
| Red | #FF0000 | rgb(255,0,0) |
| Blue | #0000FF | rgb(0,0,255) |
| Yellow | #FFFF00 | rgb(255,255,0) |
Use our free HEX to RGB Color Converter — results appear as you type. No sign-up needed!
🚀 Open HEX to RGB Color Converter Free