HEX to RGB Converter

Enter a 3- or 6-digit hex code, or pick a color, and press Convert. You get the RGB value plus RGBA, HSL, and CMYK, a preview, contrast against white and black, and related colors.

Try an example

About this HEX to RGB converter

A hex color code writes the red, green, and blue parts of a color as three pairs of base-16 digits, so #FF5733 means red FF (255), green 57 (87), and blue 33 (51). Converting it to RGB just turns each pair into a number from 0 to 255. This converter also accepts the short 3-digit form, where each digit is doubled (#F53 is #FF5533), and lets you add an opacity value for RGBA and HSLA. The contrast ratios use the WCAG 2.1 formula, so you can see straight away whether the color works as text on white or black. Hex codes are not case sensitive, so #ff5733 and #FF5733 are the same color.

How to convert HEX to RGB

  1. Enter the hex code. Type or paste a code such as #FF5733, with or without the # sign, or choose a color with the picker.
  2. Set the opacity if you need it. Move the opacity slider below 1 to get semi-transparent RGBA and HSLA values.
  3. Press Convert. Copy any format with its own button, or click a tint, shade, or matching color to copy its hex code.

Frequently asked questions

How do I convert a hex color to RGB by hand?

Split the six digits into three pairs and convert each pair from base 16 to base 10. For #3498DB, 34 is 52, 98 is 152, and DB is 219, which gives rgb(52, 152, 219).

What is a 3-digit hex code?

It is a shorthand where each digit stands for a repeated pair. #F0F expands to #FF00FF, which is magenta, rgb(255, 0, 255). Only colors whose pairs repeat can be written this way.

What is the difference between RGB and RGBA?

RGBA adds a fourth value, alpha, for opacity from 0 (fully transparent) to 1 (fully opaque). rgba(0, 0, 0, 0.5) is black at half opacity, often used for overlays and shadows.

What does the HEX8 value mean?

It is an 8-digit hex code whose last pair stores the opacity, from 00 to FF. Modern browsers accept it in CSS, so #00000080 is the same as rgba(0, 0, 0, 0.5). It only appears when the opacity is below 1.

Why is the CMYK value only approximate?

Screens mix light while printers mix ink, and real CMYK results depend on the paper and printer profile. The values here use the standard simple formula, which is fine for a starting point but not for exact print matching.