RGB to HEX Color Converter

Turn red, green, and blue channel values into six-digit HEX color codes for CSS, design systems, and web interfaces.

Last updated: March 2026 | By Workshelve Team

R
G
B

HEX Color Code

RGB Values

From RGB Channels to a HEX Color Code

RGB starts with three decimal channel values: red, green, and blue. In this converter each channel must be a whole number from 0 to 255. RGB(255, 100, 50), for example, describes a color with maximum red, a mid-low green value, and a smaller amount of blue.

A six-digit HEX color stores those same three channels as hexadecimal pairs in the order #RRGGBB. Each decimal channel is converted independently to a two-character value from 00 to FF. RGB(255, 100, 50) therefore becomes FF, 64, and 32, producing #FF6432.

Leading zeroes matter when building the final code. A channel value of 12 converts to hexadecimal C, but its HEX color pair must be 0C. This tool pads every channel to two digits and returns a normalized six-digit uppercase HEX code.

How to Convert RGB to HEX

Decimal Channel to HEX Pair

1. Start with one RGB channel
Use a whole-number channel value from 0 through 255.
2. Convert decimal to base 16
Divide by 16. The quotient gives the first HEX digit and the remainder gives the second. Values 10–15 map to A–F.
3. Pad and join the three pairs
Keep two digits for each channel, then combine red + green + blue after the # prefix: #RRGGBB.

RGB Channel Checkpoints

000
101
150F
1610
6440
12880
200C8
255FF

RGB to HEX Examples

RGB(255, 0, 0)
#FF0000
RGB(12, 34, 56)
#0C2238
RGB(34, 197, 94)
#22C55E
RGB(99, 102, 241)
#6366F1

Worked example: RGB(255, 100, 50)

Red
255 ÷ 16 = 15 remainder 15 → F and F → FF
Green
100 ÷ 16 = 6 remainder 4 → 64
Blue
50 ÷ 16 = 3 remainder 2 → 32
Result
#FF6432

RGB to HEX Frequently Asked Questions

What RGB values can I enter?

Enter whole numbers from 0 to 255 for red, green, and blue. All three channels are required before a HEX result can be calculated.

Why does each RGB channel become two HEX digits?

One 8-bit RGB channel has 256 possible values. Two hexadecimal digits also provide 256 combinations, from 00 through FF, so one pair represents one channel exactly.

Why does a small RGB value get a leading zero?

A HEX color reserves two characters for every channel. Decimal 12 is hexadecimal C, so the red, green, or blue pair is written as 0C to preserve the #RRGGBB structure.

Does this converter always return a six-digit HEX code?

Yes. RGB input is returned as a normalized six-digit #RRGGBB value, even when the same color could also be written with three-digit HEX shorthand.

What happens if an RGB value is below 0 or above 255?

The converter reports the value as invalid. It does not silently clamp out-of-range channels, because standard 8-bit RGB channels must stay between 0 and 255.

Does RGB channel order matter?

Yes. The inputs are interpreted specifically as red, green, then blue, and the output preserves that order as RR, GG, then BB. Swapping channels changes the color.

Why does RGB(255, 0, 0) become #FF0000?

Decimal 255 converts to FF, while decimal 0 converts to 00. Keeping the red, green, blue order gives FF + 00 + 00, so the final color code is #FF0000.

Does converting RGB to HEX change the color?

No. RGB and HEX are two notations for the same three 8-bit channel values. Converting the notation does not alter the underlying red, green, or blue intensities.

Related Tools