Tools

RGB to HEX Converter

Convert rgb() values to hex color codes

Sample text

Shades and tints

How to convert RGB to HEX

  1. Type the RGB value as rgb(30, 144, 255), rgba(...) or simply 30, 144, 255.
  2. Copy the hex code from the highlighted row.

The conversion

Convert each channel (0–255) to a two-digit hexadecimal number: divide by 16 for the first digit and use the remainder for the second, writing 10–15 as A–F. Then join the three pairs after a #. For rgb(30, 144, 255): 30 = 1×16 + 14 → 1E, 144 = 9×16 + 0 → 90, 255 = 15×16 + 15 → FF, so the hex code is #1E90FF. Values below 16 need a leading zero: 5 becomes 05.

RGBHEX
rgb(255, 0, 0)#FF0000
rgb(0, 255, 0)#00FF00
rgb(0, 0, 255)#0000FF
rgb(255, 255, 255)#FFFFFF
rgb(0, 0, 0)#000000
rgb(128, 128, 128)#808080
rgb(255, 165, 0)#FFA500
rgb(128, 0, 128)#800080
rgb(30, 144, 255)#1E90FF
rgb(13, 148, 136)#0D9488

If your RGB includes alpha (rgba with an opacity between 0 and 1), multiply the alpha by 255 and convert it too, giving an 8-digit hex code supported by all modern browsers. Values outside 0–255 are clamped. The conversion is exact in both directions.

FAQ

What is rgb(0, 0, 0) in hex?

#000000, which is black.

Does hex support transparency?

Yes, with 8 digits (#RRGGBBAA) in modern browsers.

Why are some hex codes three digits?

They are shorthand: #F60 means #FF6600.