HEX to RGB

Paste a HEX code and read the RGB channels. #1f5fd6 becomes rgb(31, 95, 214) — and if the code carries an alpha channel, you get rgba() with the transparency intact.

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

Contrast:

How to use

Good to know

What the six digits actually mean

HEX is a base-16 way of writing three numbers. The first pair is red, the second green, the third blue, each from 00 to FF — that is 0 to 255 in the decimal you see in RGB. A three-digit code like #1f5 is shorthand: each digit is doubled, so it expands to #11ff55.

Where RGB is required instead of HEX

Canvas and SVG APIs, Android and iOS colour objects, and anything that computes a colour rather than writing it out all speak in channels. RGB is also the only way to add transparency without an eight-digit HEX that older browsers misread.

Frequently asked questions

Does it handle an eight-digit HEX with transparency?

Yes. The last pair is the alpha channel; it appears as the fourth value in rgba(), converted from 0–255 into the 0–1 scale CSS expects.

Is the hash required?

No. «1f5fd6» and «#1f5fd6» are both accepted, as is a three- or four-digit shorthand.

Does anything leave my browser?

No. The conversion is arithmetic done on the page — nothing is uploaded or logged.

Related tools