Hex to RGB converter
This tool converts any hex colour code into its RGB equivalent and shows a live swatch. It is for developers and designers moving colours between CSS, design tools and code where one format is required and another is on hand. Paste a hex value or use the picker, and read the rgb() string plus each channel.
How it works
A hex colour encodes three 8-bit channels in base 16. The converter strips an optional leading #, and if you pass 3-digit shorthand it doubles each digit (#abc → #aabbcc). It then splits the 6 digits into three pairs and converts each pair from base 16 to a 0–255 decimal value for red, green and blue. Those become the rgb(r, g, b) string and the individual channel readouts. Anything that is not a valid 3- or 6-digit hex code is rejected with an inline message rather than a guessed colour.
Example
For #3b82f6, the three pairs convert as:
3b(hex) = 3×16 + 11 = 5982(hex) = 8×16 + 2 = 130f6(hex) = 15×16 + 6 = 246
So #3b82f6 becomes rgb(59, 130, 246).
| Hex | RGB |
|---|---|
| #000000 | rgb(0, 0, 0) |
| #ffffff | rgb(255, 255, 255) |
| #fff | rgb(255, 255, 255) |
| #ff0000 | rgb(255, 0, 0) |
| #3b82f6 | rgb(59, 130, 246) |
Everything happens in your browser — nothing is uploaded.