RGB to Hex Converter

Paste any RGB value and get the hex code back instantly, along with HSL, HSV and CMYK, all computed in your browser.

#4B994A
  • HEX#4B994A
  • RGBrgb(75, 153, 74)
  • HSLhsl(119, 35%, 45%)
  • HSVhsv(119, 52%, 60%)
  • CMYKcmyk(51%, 0%, 52%, 40%)

CMYK is a naive conversion with no colour profile, so treat it as a starting point for print rather than a match. Contrast against white is 3.53:1 for reference.

How to use RGB to Hex

  1. 1Type or paste an RGB value. Both rgb(75, 153, 74) and a bare 75, 153, 74 work.
  2. 2Read the hex code off the top row, or any of the other notations below it.
  3. 3Click a row to copy that value to your clipboard.

What happens when you convert RGB to hex

Nothing is lost and nothing is gained: they are two notations for the same three numbers. RGB writes each channel in decimal from 0 to 255, and hex writes the same channel in base 16 as two characters. rgb(75, 153, 74) and #4B994A are byte for byte the same colour.

The conversion is per channel. 75 in base 16 is 4B, 153 is 99, 74 is 4A, and concatenating them gives the hex code. That is the entire operation, which is why this page is instant and needs no file.

Why hex exists at all

Two characters per channel means a colour is always exactly six characters, which made it compact and unambiguous in early HTML and CSS. Decimal channels vary in length from one to three digits, so they need separators and a wrapper, and rgb(75,153,74) is thirteen characters against six.

Hex also aligns with how the value is stored. A colour in memory is three bytes, and one byte is exactly two hex digits, so the hex string is a direct transcription of the bytes with no arithmetic in between.

When you want RGB instead

Three situations.

Transparency, when the alpha is variable. rgba() and the modern rgb(r g b / a) syntax let you set opacity in the same declaration, and while 8-digit hex can do it too, most people find / 0.5 easier to read than 80.

Computed values, where a channel comes from a variable or an animation. Building a hex string from numbers means formatting and padding; rgb() takes the numbers directly.

Canvas and image work, where the pixel data is already three integers per pixel. Converting them to hex to hand to an API that will parse it straight back is pointless work.

The other notations on this page

HSL describes the same colour as a hue angle plus saturation and lightness, which is far easier to adjust by hand: shifting hue by 30 degrees or dropping lightness by 10 percent are single-number edits, where the equivalent in hex is three unrelated changes.

HSV is what the colour pickers in Photoshop and Figma show, so it is the notation to match when you are copying a value out of a design tool.

CMYK is included for print work, with the caveat above: without a colour profile it is an approximation.

Frequently asked questions

Why does hex use letters?
Because it is base 16, and the digits above 9 need single characters. A through F stand for 10 through 15, so one hex digit covers 0 to 15 and two cover 0 to 255, exactly one channel.
What does a 3-digit hex code mean?
Each digit is duplicated, not padded. #ABC expands to #AABBCC, so the A becomes 0xAA (170) rather than 0xA0 (160). This shorthand can only express colours where both digits of each channel match, which is 4096 of the 16.7 million.
Which format should I use in CSS?
Hex for opaque colours, since it is compact and universally understood. rgb() when you need a variable alpha, or when a value is being computed rather than written by hand. Modern CSS accepts both everywhere.
Is the CMYK value accurate for print?
No, and no browser tool's is. Proper CMYK depends on an ICC profile for the specific paper and press. The value here is the naive formula, useful as a starting point and not as a proof.

More free tools