HEX → RGB

Convert HEX colour codes to RGB values

HEX is the shorthand designers and CSS use; RGB is what most programming interfaces, canvas APIs and design tool inputs expect. They describe exactly the same colour in different notation, so converting between them is lossless and exact.

How to use it

  1. Enter a HEX code such as #3b82f6. The hash is optional.
  2. The RGB values appear immediately alongside a colour preview.
  3. Confirm the swatch matches what you expected.
  4. Copy the rgb() string for use in your code.

Frequently asked questions

How does the three-character shorthand work?

Each digit is doubled, so #f0a expands to #ff00aa. It is a convenience that only works when both digits of every channel happen to match, which is why not every colour has a short form.

What do the two hex digits per channel mean?

Each pair is one byte, from 00 to ff, giving 0 to 255 in decimal for red, green and blue respectively. So #3b82f6 is red 59, green 130, blue 246.

What about eight-digit HEX codes?

The final pair is alpha, the opacity channel, again from 00 to ff. That maps to the fourth value in an rgba() colour, expressed there as a decimal from 0 to 1.

Is any colour accuracy lost?

None. Both notations describe the same 24-bit colour space, so conversion in either direction is exact and fully reversible.