RGB to HEX

Paste rgb(31, 95, 214) — with commas or spaces, it does not matter — and get #1f5fd6, ready for CSS, a design file or a style guide.

  • #1f5fd6 HEX
  • rgb(31, 95, 214) RGB
  • hsl(219, 75%, 48%) HSL

Contrast:

How to use

  1. Paste the RGB or RGBA value, or pick a colour with the swatch.
  2. Read the HEX code above the other formats.
  3. Press «Copy» next to the HEX line.

Good to know

Why designers ask for HEX

HEX is one token instead of three numbers, which makes it easy to paste into a spec, a ticket or a chat message without losing a digit. It is also the notation that design tools show by default, so a palette written in HEX matches what everyone else is looking at.

What happens to the alpha channel

If you pass rgba() with transparency, the result is an eight-digit HEX: the last pair encodes alpha from 0 to 255. Modern browsers read it correctly; older ones do not, so keep rgba() where you need broad support.

Frequently asked questions

Do I have to write rgb(...) around the numbers?

The full notation with commas or spaces is accepted, in both rgb() and rgba() form. Values above 255 are clamped rather than silently wrapped.

Why is my HEX eight characters long?

Because the colour has an alpha channel. Drop the transparency and you get the usual six-digit code.

Is anything sent to a server?

No. The whole conversion happens in the page, so unpublished brand colours stay with you.

Related tools