How to convert RGB to HEX
Enter the red, green, and blue values (each between 0 and 255) into the three input fields. The hex code updates in real time — no button press needed. The tool also outputs the HSL equivalent and ready-to-paste CSS expressions.
Use the quick swatches to explore how common colors translate to hex, or type values directly. Decimal values are accepted and rounded automatically.
RGB to HEX conversion formula
Each RGB channel (0–255) is converted independently to a 2-digit hexadecimal number. The three results are concatenated with a # prefix.
| Channel | Decimal | Hex |
|---|---|---|
| R (Red) | 255 | FF |
| G (Green) | 87 | 57 |
| B (Blue) | 51 | 33 |
Result: rgb(255, 87, 51) → #FF5733
When to use hex vs RGB in CSS
- Use hex for static color values, design tokens, and brand colors — it is more compact and universally supported.
- Use rgb() when you need transparency via
rgba(), or when computing colors programmatically. - Use hsl() when you want to create tints and shades by adjusting lightness — more intuitive than modifying hex digits.