DevBolt

RGB to HEX Converter

Convert RGB color values to HEX codes instantly. Enter red, green, and blue values (0–255) and get the corresponding HEX code with a live color preview.

← Back to tools

Color Converter

Convert colors between HEX, RGB, and HSL formats.

How RGB to HEX conversion works

Each RGB value (0–255) is converted to a two-digit hexadecimal number. Red 255 → FF, Green 87 → 57, Blue 51 → 33, combined as #FF5733. The formula: hex = '#' + r.toString(16).padStart(2, '0') + g.toString(16).padStart(2, '0') + b.toString(16).padStart(2, '0').

Shorthand HEX codes

When each hex pair has identical digits (e.g., #FF5533), some pairs can be shortened: #AABBCC → #ABC. However, #FF5733 cannot be shortened because 57 and 33 have different digits. CSS supports both 3-digit and 6-digit HEX codes.

Frequently Asked Questions

How do I convert RGB 255, 0, 0 to HEX?

RGB(255, 0, 0) = #FF0000. Red: 255 → FF, Green: 0 → 00, Blue: 0 → 00. This is pure red.

What is the HEX code for white?

#FFFFFF — all channels at maximum (RGB 255, 255, 255). In shorthand: #FFF.