From three numbers to one code
Screens mix red, green and blue light, each from 0 to 255. Hex notation writes those three numbers as two hexadecimal digits each and joins them: rgb(30, 144, 255) becomes #1E90FF. Hex is the format used in CSS, HTML, Figma, brand guides and most design tools, so it is the usual way to share a colour.
This converter accepts the formats you are likely to paste: rgb(255, 136, 0), the modern rgb(255 136 0 / 50%), rgba(…), percentages, or just three numbers. With transparency, the result is an eight-digit code such as #FF880080.
Worked example
rgb(30, 144, 255): 30 = 1 × 16 + 14 → 1E; 144 = 9 × 16 + 0 → 90; 255 → FF. The code is #1E90FF, the CSS colour named dodgerblue. Its contrast against white is 3.04:1: fine for large headings and icons, too low for body text.
How this works
The page reads the three channel values, clamps them to 0–255 (percentages are multiplied by 2.55), rounds them, and writes each one as two hexadecimal digits, padding with a leading zero when needed. An alpha value below 1 adds a fourth pair, the alpha multiplied by 255. The table shows the same colour in HSL, HSV and naive CMYK, and the WCAG contrast ratios against white and black. Everything runs in this tab.
Frequently asked
How do I convert RGB to hex by hand?
Divide each value by 16: the quotient and remainder are the two hex digits. 200 = 12 × 16 + 8 → C8.
What about rgba transparency?
Alpha becomes a fourth pair: 50% is 80 (128 in decimal), so rgba(255, 136, 0, 0.5) is #FF880080.
Why was my value changed to 255?
Channels above 255 or below 0 are clamped, which is what browsers do.
Uppercase or lowercase hex?
Either. CSS does not care; the page uses lowercase.
Sources
- W3C — CSS Color Module Level 4
- W3C — Web Content Accessibility Guidelines (WCAG) 2.2
- Wikipedia — Web colors
Reviewed Oct 17, 2026 · test vectors fixtures/dev/rgb-to-hex/