RGB to HEX Converter
Turn red, green and blue values (0–255) into a hex color code for CSS and HTML, with optional alpha and every other format.
-
hex
-
rgb
-
hsl
-
hwb
-
oklch
-
cmyk
Runs in your browser. What you enter is kept for 30 days to improve Toolgrid, then deleted.
How to use the RGB to HEX Converter
- 1 Enter red, green and blue from 0 to 255, or drag the sliders.
- 2 Optionally set alpha from 0 (transparent) to 1 (opaque).
- 3 Copy the hex code, or any other format, from the list.
About the RGB to HEX Converter
Each RGB channel from 0 to 255 is written as two hexadecimal digits: 13 becomes 0d, 148 becomes 94 and 136 becomes 88, giving #0d9488. Hex codes are the most common way to write colors in CSS, HTML and design handoffs.
Decimal values are rounded to the nearest whole number before converting, and values below 0 or above 255 are clamped, because a channel cannot go outside that range.
With an alpha below 1 you get an 8-digit hex code (#rrggbbaa) and an rgba() value. All modern browsers understand 8-digit hex codes.
Frequently asked questions
How is RGB converted to hex?
Each channel is converted to base 16 and padded to two digits, then the three pairs are joined behind a #.
What if I enter 300 or -5?
The value is clamped to 255 or 0, the nearest valid value.
Can I convert rgba() with transparency?
Yes. Set alpha and the tool gives an 8-digit hex code such as #0d948880.
Are hex codes case-sensitive?
No. #0D9488 and #0d9488 are the same color; this tool writes lower case.