How to Convert HEX to RGB

HEX codes and RGB values describe the same colours in two different notations: #FF5733 and rgb(255, 87, 51) are the same orange. Designers copy HEX from Figma; developers often need RGB for CSS functions, canvas work, or colour maths. This guide shows you how to convert between them instantly — and how the conversion works, so you can do it by hand when you need to.

HEX and RGB: the same colour, two notations

Two digits per channel

A HEX code is a colour written in base 16: two digits for red, two for green, two for blue. In #FF5733, the red channel is FF, the green channel is 57 and the blue channel is 33. RGB writes the same three channels in base 10, each from 0 to 255: rgb(255, 87, 51). Both notations describe the same 16.7 million colours, and every HEX code has exactly one RGB equivalent.

Different tools prefer different forms

The two notations exist because different tools prefer different forms. Design tools and brand guidelines use HEX because it is compact — six characters, easy to copy. Code often needs RGB, because CSS functions like rgba() take RGB numbers plus an alpha value, and canvas and image processing work in RGB natively.

Converting by hand

Split into pairs, convert each one

Split the HEX code into three pairs, one per channel, and convert each pair from base 16 to decimal. Each pair is the first digit times 16 plus the second digit, where A is 10, B is 11, C is 12, D is 13, E is 14 and F is 15. So 57 becomes 5 times 16 plus 7, which is 87. And 33 becomes 3 times 16 plus 3, which is 51. FF is 15 times 16 plus 15, which is 255.

Three-digit HEX: double each digit

Three-digit HEX is a shorthand: double each digit. #F53 expands to #FF5533 — red FF, green 55, blue 33. It only works when each pair has two identical digits. To go the other way, divide each RGB number by 16: the quotient is the first hex digit and the remainder is the second. For 87: 87 divided by 16 is 5 remainder 7, so the pair is 57.

Convert HEX to RGB in four steps

  1. Enter your HEX code. Open the HEX to RGB Converter and type the code, with or without the hash sign, in 3-digit or 6-digit form. The conversion happens as you type.
  2. Read the RGB values. Three numbers from 0 to 255, one per channel. The converter also shows the HSL values — hue, saturation and lightness — which are useful when you want to adjust the colour rather than just convert it.
  3. Copy the format you need. Use the copy buttons for the exact format: rgb(255, 87, 51) for CSS, the HEX code for a design tool, or hsl(11, 100%, 60%) for a lightness adjustment.
  4. Check the colour on the swatch. The preview shows the actual colour. If it looks nothing like what you expected, the code was probably mistyped — a single wrong digit can turn a warm orange into a muddy green.

Where each format is used

HEX is the default in CSS, design tools and brand guidelines, because it is short and unambiguous. RGB is used where transparency or maths is involved: rgba() for semi-transparent colours, canvas drawing, and image processing. HSL is the format for adjustments — making a colour lighter or darker, or desaturating it, is a one-number change in HSL and a three-number calculation in RGB.

Most modern CSS accepts all three, so the choice is usually about what the next person reading the code will find clearest. Brand colours are almost always written in HEX; computed colours are usually RGB or HSL.

Other ways to convert

Your browser's DevTools can do it: click a colour swatch in the Styles panel and it cycles through HEX, RGB and HSL. Design tools like Figma and Sketch show all three formats in the colour picker. And a quick web search for a code like #FF5733 to RGB returns the answer directly.

The converter is fastest when you are converting several colours at once, or when you want the HSL values and a preview swatch alongside the RGB numbers.

Related guides

Questions people ask

What does FF mean in a HEX code?

FF is the hexadecimal value 255, the maximum for one colour channel. In #FF0000, the red channel is at full strength and green and blue are zero, which makes pure red.

What is 3-digit HEX?

A shorthand where each digit is doubled: #F53 expands to #FF5533. It works only when each pair has two identical digits.

How do I convert RGB back to HEX?

Divide each RGB number by 16. The quotient is the first hex digit and the remainder is the second, with 10 becoming A and 15 becoming F. For 87: 87 divided by 16 is 5 remainder 7, so 57.

What is HSL?

HSL stands for hue, saturation and lightness. It describes a colour by its position on the colour wheel, how vivid it is, and how light or dark it is. It is handy when you want to make a colour lighter or darker without changing its hue.