0xCONVERTER-HEX

rgb() → hex

RGB to Hex Converter

Turn red, green and blue channel values into a hexadecimal color code.

RGB in
Or pick

Hex

RGB

HSL

Channels

Contrast

How to convert RGB to hex

  1. Take the red value and convert it to hex.
  2. Pad it to two digits with a leading zero if needed — this step is not optional.
  3. Do the same for green, then blue.
  4. Join the three pairs in that order and put a # in front.

Worked example

rgb(26, 115, 232)

  red     26 ÷ 16 =  1 remainder 10  → 1A
  green  115 ÷ 16 =  7 remainder  3  → 73
  blue   232 ÷ 16 = 14 remainder  8  → E8

  result → #1A73E8
The padding rule

A channel value below 16 converts to a single hex digit and must be padded. Red 5 is 05, not 5. Skip the zero and rgb(5, 5, 5) becomes #555 — a mid grey instead of a near-black.

Channel order never changes

Red, then green, then blue. Always. It is worth stating because other formats disagree and the mix-up is a genuine source of bugs.

ContextOrderNote
CSS hex, rgb()R G BThe web standard
Windows COLORREFB G RReversed — a classic source of blue/red swaps
Android color intA R G BAlpha first, not last
CSS 8-digit hexR G B AAlpha last

If a color comes out looking like its opposite, a reversed channel order is the first thing to check.

Values that do not fit

Channels run from 0 to 255, and anything outside that range is not a color. Percentages are a different notation entirely: rgb(50%, 50%, 50%) means 128, not 50. This converter accepts plain numbers from 0 to 255 and tells you when a value falls outside.

Fractional values are also common from design tools and interpolation. They must be rounded before conversion, because a hex digit cannot express a fraction — 26.4 and 26.5 both have to land on a whole channel value.

Quick conversions

RGBHexColor
0, 0, 0#000000Black
255, 255, 255#FFFFFFWhite
128, 128, 128#808080Mid grey
255, 0, 0#FF0000Red
0, 128, 0#008000CSS green
0, 0, 255#0000FFBlue
255, 165, 0#FFA500Orange
26, 115, 232#1A73E8A typical link blue

Note that CSS green is #008000, not #00FF00. The full-brightness version is called lime, which surprises almost everyone the first time.

Frequently asked questions

How do I convert RGB to hex?

Convert each channel value to hex, pad each to two digits, then join them in red, green, blue order with a # in front.

What is rgb(255, 0, 0) in hex?

#FF0000, which is pure red.

Why do I need to pad with a leading zero?

Every channel must occupy exactly two digits. Writing 5 instead of 05 shifts the other channels and produces a completely different color.

What is the maximum RGB value?

255 per channel, which is FF in hex. That is 256 levels counting zero.

How do I include opacity?

Multiply the 0 to 1 alpha by 255, convert to hex and append it as a fourth pair. 50% opacity is roughly 80.

Why is CSS green not #00FF00?

The name green was defined as #008000 and kept for compatibility. The full-brightness color is named lime.