CODDY Tool

RGB to HEX

Convert RGB values to a hex colour code.

Enter red, green and blue values and get the hex code straight away. Accepts rgb() and rgba() in comma or space syntax, and produces an eight-digit hex when alpha is below one.

Everything you enter stays in this browser tab. Nothing is sent to our servers, logged or stored.

This is one of the thingsColor Converterdoes — open it for everything else it supports.

Loading tool…

What Color Converter supports

  • HEXThe web default, with optional alpha.
  • RGBRed, green and blue from 0 to 255.
  • HSLHue, saturation and lightness.
  • HSVThe model behind most colour pickers.
  • CMYKFour-colour process, for print.
  • OKLCHPerceptually even; modern CSS.

About RGB to HEX

Going from RGB to hex means writing each channel in base 16 and padding it to two digits. 74 becomes 4a, 73 becomes 49, 216 becomes d8, giving #4a49d8. The padding matters: a value under 16 produces a single digit that must be written as 0f rather than f, or the whole code shifts and the colour comes out wrong.

If your colour has an alpha below 1, the modern eight-digit hex form encodes it as a fourth pair. Support is universal in current browsers, so rgba(74, 73, 216, 0.5) can be written as #4a49d880 with no compatibility concern.

Hex remains the most portable way to write a colour down. Every design tool, every CSS file and every configuration format accepts it, which is why it is still the default despite being the least human-readable of the formats.

How to convert RGB to HEX

  1. Enter your RGB values

    Paste rgb(74 73 216) or rgb(74, 73, 216). Both syntaxes are accepted, with or without an alpha value.

  2. Copy the hex code

    The highlighted row gives the hex value. An alpha below 1 produces the eight-digit form automatically.

  3. Adjust if you want to

    The hue, saturation and lightness sliders change the colour, and the hex code follows as you drag.

Frequently asked questions

How do I convert RGB to hex manually?

Divide each channel by 16. The quotient is the first hex digit and the remainder is the second, using a–f for 10 to 15. So 216 gives 13 remainder 8, which is d8. Always write two digits per channel.

What happens to the alpha value?

It becomes a fourth pair of digits: multiply by 255 and write the result in hex. An alpha of 0.5 gives 80. Leaving alpha at 1 produces the ordinary six-digit code.

Can every RGB colour be written as hex?

Every integer RGB value, yes. Fractional values cannot — hex stores whole numbers from 0 to 255 per channel — so rgb(74.6 73 216) rounds to the nearest whole number first. The difference is not visible on any display.

Is eight-digit hex safe to use in production?

Yes. Every browser in current use supports it, and has for years. The only places to be careful are older email clients and some design tools, which still expect six digits and may ignore the alpha pair entirely.

RGB to HEX is free to use with no account, no watermark and no usage limits. Last updated 14 August 2026.