Taking a computed colour into CSS
A colour produced in code as RGB converts to the hex a stylesheet or design tool expects.
Convert an RGB colour to a hex code in your browser, from any common RGB format.
Maintained by Roshan.
Converts rgb colour to hex in this tab, with nothing sent anywhere.
Find related browser-local tools for nearby tasks without starting another search.
Browse all general convertersConverting RGB to hex is the return trip, and it is the one you make when a colour has come out of code or a calculation and now needs to go into CSS, a design file, or anywhere that expects the compact six-digit form. RGB expresses a colour as three numbers from 0 to 255; hex packs those same three numbers into two digits each. The small friction is that RGB arrives written in many ways - the full rgb(59, 130, 246), or just three numbers, or space-separated, or with stray punctuation - and a rigid parser rejects all but its preferred shape. This tool pulls the three channel values out of whatever form they are in, checks each is within range, and assembles the hex code, so a value from any source converts without being reformatted first.
A colour produced in code as RGB converts to the hex a stylesheet or design tool expects.
Values written in different RGB styles all convert to the same tidy hex form.
Full rgb() notation, bare comma-separated numbers, and space-separated values all work. The three channels are extracted from any of them.
It is refused with a message, since it is outside the valid range rather than a value to guess at.
The alpha of an rgba value is ignored; the result is the opaque hex colour.
The output is lower case, which is equivalent to upper case for a colour.
Convert a hex colour to RGB in your browser, accepting both three and six digit forms.
Convert a hex colour to HSL in your browser, the model that makes colours easy to adjust.
Convert text to hexadecimal in your browser. Each character becomes its UTF-8 bytes in hex.