FT

RGB to HEX Converter

Convert RGB values to HEX color codes instantly. Supports rgba() with alpha transparency to produce 8-digit HEX codes.

236
72
153

How to Convert RGB to HEX

Enter the Red, Green, and Blue values (each from 0 to 255) into the input fields. The tool instantly generates the corresponding HEX code, ready to copy into CSS, Figma, or any design tool. If you provide an optional alpha value, the result becomes an 8-digit HEX code with embedded transparency.

RGB vs HEX: Which to Pick for Your Project

Use HEX in static CSS, design files, brand documents, and anywhere humans will read the value. Use RGB when working with JavaScript, color animations, dynamic theming, image processing, or when you need fine-grained control over individual channels. Most workflows mix both — you might design in HEX, then convert to RGB at runtime for animation.

How the Math Works

Convert each decimal (0–255) to a 2-character hexadecimal string, then concatenate. For example: 255 in hex is FF, 87 is 57, 51 is 33 → #FF5733. Pad single-digit results with a leading zero (5 becomes 05). The tool handles all edge cases automatically.

Working with rgba() Alpha Channel

When you specify an alpha value between 0 and 1, the tool converts it to a hex byte (0.5 → 80, 0.8 → CC) and appends it to the HEX code. The resulting 8-digit format (#RRGGBBAA) works in all modern browsers and Tailwind CSS. For older browser support, stick with the rgba() syntax.

❓ Frequently Asked Questions

How is RGB converted to HEX?
Each RGB channel (0–255) is converted to a 2-digit hexadecimal number, then concatenated. For rgb(255, 87, 51): 255 = FF, 87 = 57, 51 = 33 → #FF5733.
What if my RGB value is out of range?
Standard RGB channels are 0–255. If you input values outside this range, the tool will clamp them automatically (negative becomes 0, above 255 becomes 255) and warn you of the adjustment.
Can I convert rgba() with alpha to HEX?
Yes. When you provide an alpha value, the tool outputs an 8-digit HEX code (#RRGGBBAA). For example, rgba(255, 87, 51, 0.8) becomes #FF5733CC. Modern browsers support this format directly in CSS.
Why are HEX codes used so often in design?
HEX is compact (7 characters vs ~17 for rgba()), case-insensitive, and copy-paste-friendly. Every major design tool — Figma, Sketch, Adobe XD, Canva — uses HEX as the default exchange format for colors.

Related Color Tools

More Tools