Enter a RGB colour. Any supported format is accepted, and the result updates as you type.
This box works in both directions — change it and the RGB value follows.
All formats
-
HEX
— -
HEX8
— -
RGB
— -
RGBA
— -
HSL
— -
HSV
— -
CMYK
—
Every value shown comes from one conversion of the colour above, so the HEX, RGB, HSL and CMYK rows always agree with each other.
Your colours are converted in this browser. Nothing is uploaded and nothing is saved.
Turn channel values into a hex code. Each of the three numbers becomes one byte written in base sixteen, padded to two characters — so 79 becomes 4F, 142 becomes 8E and 247 becomes F7.
The box works in both directions. Paste an rgb() value from a stylesheet or a graphics API and take the hex code, or go the other way and type a hex code to see its channels.
How to use this tool
- Paste an rgb() or rgba() value into the top box.
- Read the hex code beside it, or pick a colour from the field if that is easier.
- Values outside 0-255 are clamped rather than wrapped, so a typo cannot silently produce a different colour.
- Copy the hex code, or any other format listed underneath.
One channel, two characters
A channel from 0 to 255 fits in one byte, and one byte in hex is exactly two characters. 255 is FF, 0 is 00 and 128 is 80 — so rgb(79, 142, 247) becomes #4F8EF7, and each character pair can be read back on its own.
Percentages and out-of-range values
rgb(50%, 0%, 0%) is valid CSS and means half of 255, which is 128 — #800000. The tool reads percentages as well as numbers, and clamps anything outside the range: rgb(300, -20, 128) is treated as rgb(255, 0, 128) rather than quietly wrapping around to a different colour.
Where alpha goes
rgba() carries a fourth value from 0 to 1. In hex there is no separate alpha notation, so it becomes an extra pair of digits at the end: rgba(79, 142, 247, 0.5) is #4F8EF780, where 80 is 128 of a possible 255.
Frequently asked questions
How do I convert rgb(255, 0, 0) to hex?
#FF0000. 255 is FF and 0 is 00, once per channel.
Can I paste percentages instead of numbers?
Yes. rgb(100%, 50%, 0%) is read as rgb(255, 128, 0) and converted the same way.
Does it accept rgba()?
Yes, and the result gains an 8-digit hex code with the alpha pair appended.
Why is #FF0000 red?
The first pair is the red channel, and FF is its maximum. The other two channels are 00, so green and blue contribute nothing.