Free tool

RGB to HEX converter

Type an rgb() color to get its hex code, or edit the hex field to go the other way. The color picker and HSL value update as you type.

#1E90FF = rgb(30, 144, 255) = hsl(210, 100%, 56%)

How to convert RGB to HEX

An RGB color has three channels, red, green and blue, each from 0 to 255. A hex color code writes each channel as a two-digit hexadecimal number, so the format is #RRGGBB. To convert by hand:

  1. Take one channel, for example red = 255.
  2. Divide by 16: the whole number is the first digit, the remainder the second. 255 ÷ 16 = 15 remainder 15.
  3. Write 10 to 15 as A to F: 15 and 15 become FF.
  4. Repeat for green and blue and join them: rgb(255, 99, 71) becomes #FF6347.

Going the other way? Use the HEX to RGB converter.

RGB to HEX color chart

ColorRGBHEX
Blackrgb(0, 0, 0)#000000
Whitergb(255, 255, 255)#FFFFFF
Redrgb(255, 0, 0)#FF0000
Limergb(0, 255, 0)#00FF00
Bluergb(0, 0, 255)#0000FF
Orangergb(255, 165, 0)#FFA500
Goldrgb(255, 215, 0)#FFD700
Tomatorgb(255, 99, 71)#FF6347
Tealrgb(0, 128, 128)#008080
Slate grayrgb(112, 128, 144)#708090
Indigorgb(75, 0, 130)#4B0082
Hot pinkrgb(255, 105, 180)#FF69B4

Decimal to hex for one channel

Common channel values and their two-digit hex codes:

DecimalHex
000
1711
3422
5133
6844
8555
10266
11977
12880
13688
15399
170AA
187BB
204CC
221DD
238EE
255FF

RGBA to HEX

CSS also accepts 8-digit hex codes, where the last two digits are the alpha (opacity). Multiply the alpha by 255 and convert it like any other channel: 1 = FF, 0.75 ≈ BF, 0.5 ≈ 80, 0.25 ≈ 40 and 0 = 00. So rgba(30, 144, 255, 0.5) is #1E90FF80.

Check these values on any live website

Traceo is a free Chrome extension that shows the real CSS on any page: hover an element to read its colors in HEX and RGB, font sizes in px and rem, spacing, and contrast, then record and share UI bugs with console and network logs.

FAQ

How do you convert RGB to HEX?

Convert each of the red, green and blue values (0 to 255) to a two-digit hexadecimal number, then join them after a # sign. For rgb(255, 99, 71): 255 = FF, 99 = 63, 71 = 47, so the hex code is #FF6347.

How do you convert a single number from decimal to hex?

Divide the number by 16. The whole part is the first hex digit and the remainder is the second, where 10 to 15 are written A to F. For 99: 99 ÷ 16 = 6 remainder 3, so 99 is 63 in hex.

How do I convert RGBA to HEX?

Convert red, green and blue as usual, then convert the alpha to a two-digit hex value by multiplying it by 255 and rounding. rgba(255, 99, 71, 0.5) becomes #FF634780, because 0.5 × 255 ≈ 128 = 80 in hex.

Is RGB or HEX better for CSS?

They describe the same colors, so use whichever is easier to read. Hex is shorter and easy to copy from design tools; rgb() is clearer when you need to adjust a channel or add transparency with rgb(255 99 71 / 50%).

Why does my HEX code have letters?

Hexadecimal counts from 0 to 15 in a single digit, using A to F for 10 to 15. Two hex digits cover 0 to 255, which is exactly the range of one RGB channel.

How do I get the RGB or HEX value of a color on a website?

With the Traceo Chrome extension, hover any element to see the colors the page renders in both HEX and RGB, or list the full color palette of the page.

More free tools