RGB to Hex Converter

Enter red, green, and blue values (0–255) to get the matching hex color code. The conversion happens instantly as you type, and one click copies the hex code for CSS, design tools, or emails.

RGB → Hex

#2d6a4f

Hex → RGB

rgb(45, 106, 79)

Going this direction often? The dedicated hex to RGB converter has its own worked examples and FAQs.

Got your hex code? Generate its full range of tints and shades with the free HexTints generator, or look it up in the color library for precomputed values and WCAG contrast notes.

How RGB to Hex Conversion Works

A hex color code is the same three RGB channels written in base 16. Each channel value (0–255) becomes a two-digit hex pair, and the pairs are joined in red, green, blue order behind a #.

To convert a value by hand, divide it by 16: the quotient is the first hex digit and the remainder is the second. Digits above 9 use letters — 10 is A, 11 is B, up to 15 as F. So for 45: 45 ÷ 16 = 2 remainder 13, and 13 is D, giving 2D.

Worked Example: rgb(45, 106, 79)

rgb(45, 106, 79)
 ├─ 45  ÷ 16 = 2 remainder 13 → 2D  (red)
 ├─ 106 ÷ 16 = 6 remainder 10 → 6A  (green)
 └─ 79  ÷ 16 = 4 remainder 15 → 4F  (blue)

Result: #2D6A4F

Values below 16 divide to a quotient of 0 and keep a leading zero, so rgb(0, 128, 5) becomes #008005.

When You Need Hex vs rgb()

In CSS you rarely have to convert: background: rgb(45 106 79) and background: #2d6a4f render identically. Hex wins where a single compact token matters — design-system tokens, brand guidelines, email HTML, and the color fields in tools like Figma and Photoshop all expect hex. rgb() and rgba() are handy when you're already working with channel numbers or need alpha in older browsers.

Working in HSL instead? Use the HSL to hex and hex to HSL converters, or pick a color visually with the color picker.

Common Colors as RGB and Hex

ColorRGBHex
Redrgb(255, 0, 0)#FF0000
Greenrgb(0, 128, 0)#008000
Bluergb(0, 0, 255)#0000FF
Orangergb(255, 165, 0)#FFA500
Whitergb(255, 255, 255)#FFFFFF
Blackrgb(0, 0, 0)#000000

Shorthand and Alpha

3-digit shorthand: when each hex pair repeats its digit, the code can be halved — #ffaa33 is #fa3. That only works for repeating pairs, so #2d6a4f has no shorthand form.

Alpha: rgba() maps to 8-digit hex. Convert the three channels normally, then multiply the alpha (0–1) by 255 and append it as a fourth pair: rgba(45, 106, 79, 0.5) → 0.5 × 255 ≈ 128 → 80#2D6A4F80.

Frequently Asked Questions

Related tools: hex to RGB · HSL to hex · hex to HSL · color picker · tint & shade generator

Got your hex code? Put it to work on a page that's yours — create your free MinglyLink page →