SuperDevTools

HEX to RGB Converter

  • RGB
  • HSL
  • CMYK

From a HEX code to RGB values

A hexadecimal code such as #2e8b57 is the usual way to write a color on the web and in design files. RGB describes the same color with three numbers from 0 to 255: how much red, green and blue the screen lights up. This converter translates one into the other as you type. Everything happens in your browser and nothing is sent to a server. The RGB to HEX converter does the reverse.

You need RGB as soon as you have to work with the channels themselves: writing rgba() with some transparency, filling in the R, G and B fields of an application, or computing contrast in a script. For a ready-made contrast figure without any script, the color contrast checker gives the WCAG ratio directly. And to lighten or darken the shade, the HEX to HSL converter is easier to read.

How to use it

  1. Type the HEX code, with or without the #, or pick a shade with the color picker.
  2. Check the color in the preview.
  3. Read the highlighted RGB line and click Copy. The HSL and CMYK equivalents are listed below, each with its own button.

If the code is not recognised, a message shows an example of valid input.

The calculation, with an example

A HEX code is read in pairs: two digits for red, two for green, two for blue. Each pair is a base-16 number in which the letters a to f stand for 10 to 15. Multiply the first digit by 16 and add the second. For #2e8b57:

  • red: 2e = 2 × 16 + 14 = 46
  • green: 8b = 8 × 16 + 11 = 139
  • blue: 57 = 5 × 16 + 7 = 87

The result is rgb(46, 139, 87), a sea green. The conversion is exact: no rounding is involved, and both notations describe precisely the same color.

ColorHEXRGB
Coral#ff7f50rgb(255, 127, 80)
Steel blue#4682b4rgb(70, 130, 180)
Gold#ffd700rgb(255, 215, 0)
Purple#800080rgb(128, 0, 128)
Beige#f5f5dcrgb(245, 245, 220)

Frequently asked questions

Does upper or lower case change the color?

No. #2E8B57 and #2e8b57 are the same color, and the tool accepts both.

What does a three-digit code like #36c mean?

It is the short form: each digit is doubled. #36c is the same as #3366cc, which gives rgb(51, 102, 204).

What about eight-digit codes with transparency?

They are not supported. Drop the last two digits, which hold the opacity, convert the first six, then add the alpha value yourself in rgba().

Why is 255 the maximum?

Two hexadecimal digits give 16 × 16 = 256 values, from 0 to 255. ff equals 15 × 16 + 15 = 255, the full intensity of a channel.