PDF guide

How to Convert RGB to a Hex Color

RGB and hexadecimal colors describe the same three channels in different number systems. Validate each channel, convert it to two digits, and check the visible swatch.

smallpdf.app editorial team Published 5 min read
Illustrated RGB channel controls becoming a hexadecimal color swatch

RGB and hex describe the same channels

An RGB color has red, green, and blue channels from 0 through 255. A six-digit hexadecimal color writes those same channels as pairs from 00 through FF. The RGB to Hex converter validates the three integers and returns the CSS-ready #RRGGBB form.

Convert each channel to two digits

For example, decimal 91 becomes hexadecimal 5B, 76 becomes 4C, and 230 becomes E6. Joining those pairs produces #5B4CE6. Leading zeroes matter: decimal 5 must be written as 05, not 5.

Check the visible swatch

Copying the number accurately is only part of color work. Review the preview against the surrounding background, and consider contrast for text and controls. Different displays and color profiles can still make the same numeric color appear slightly different.

Know what is not included

Six-digit hex has no opacity channel. CSS can use an eight-digit form or a modern RGB syntax when alpha is required. The converter intentionally returns the widely supported opaque #RRGGBB value.