RGB to HEX Converter
RGB to HEX Converter turns red, green and blue channel values into a hexadecimal color code you can drop straight into CSS or a design tool. It also shows the HSL equivalent and a live swatch.
Type each channel from 0 to 255 and the matching HEX value appears instantly, ready to copy.
rgb(124, 58, 237)#7c3aedhsl(262, 83%, 58%)How to use RGB to HEX Converter
- 1
Enter RGB values
Set the R, G and B channels, each from 0 to 255.
- 2
Read the HEX code
The matching #rrggbb value updates live, alongside HSL.
- 3
Copy what you need
Copy the HEX string into your stylesheet or design file.
How RGB maps to HEX
An RGB color describes three channels — red, green and blue — as numbers from 0 to 255. A HEX code encodes the same three channels as two hexadecimal digits each, so rgb(255, 0, 0) becomes #ff0000.
Because both formats describe the exact same sRGB color, the conversion is lossless: any RGB triple has a single HEX representation and vice versa.
When to use HEX over RGB
HEX is the most compact way to write an opaque color and is the format you will see most often in CSS, design handoffs and brand guidelines.
Reach for RGB (or rgba) when you need transparency or want to tweak a single channel programmatically. The two are interchangeable, so keep whichever your toolchain prefers.
Frequently asked questions
- What range do RGB values use?
- Each channel runs from 0 to 255. Values outside that range are not valid and the converter will wait for a correct value.
- Is the conversion lossless?
- Yes. RGB and HEX describe the same color space, so converting between them never loses information.
Last updated: