Pixel Color Picker

RGB to HEX Converter

Enter a RGB color below to get the exact HEX value instantly, plus every other format, right in your browser.

Input: RGB

Optional A (0 to 1) adds an alpha pair to the HEX result.

Result: HEX

#1E90FF

All formats

HEX

#1E90FF

RGB

rgb(30, 144, 255)

HSL

hsl(210, 100%, 56%)

HSV

hsv(210, 88%, 100%)

CMYK

cmyk(88%, 44%, 0%, 0%)

When you need RGB to HEX

Colors often arrive as rgb() strings or integer triples. The getComputedStyle call returns colors in rgb() form, Canvas getImageData yields plain numbers, and image libraries print tuples. When you need to store that color in a design token file, a Tailwind config, an SVG fill or an HTML email, one HEX string is shorter and easier to compare in a diff. Enter the three channels here to get the six-digit code, then see whether it can be shortened to three digits.

Typical uses

How to convert RGB to HEX

A HEX color code is the same RGB color written in hexadecimal (base-16). The six characters after the # sign form three pairs (RR, GG and BB), one pair per channel.

To convert HEX to RGB, translate each pair from base-16 to decimal: FF equals 255, 57 equals 87, 33 equals 51. To convert RGB to HEX, write each channel value (0-255) as a two-digit hexadecimal number.

Worked example

  1. R: 30 ÷ 16 = 1, remainder 14 → 1E
  2. G: 144 ÷ 16 = 9, remainder 0 → 90
  3. B: 255 ÷ 16 = 15, remainder 15 → FF

rgb(30, 144, 255) = #1E90FF

Tip: If your numbers come from OpenCV, remember that it stores channels in B, G, R order by default. Reorder them to R, G, B before entering them here, otherwise the HEX will show red and blue swapped and the color will look wrong.

Common colors: RGB to HEX

ColorRGBHEX
Redrgb(255, 0, 0)#FF0000
Orangergb(255, 165, 0)#FFA500
Yellowrgb(255, 255, 0)#FFFF00
Limergb(0, 255, 0)#00FF00
Greenrgb(0, 128, 0)#008000
Cyanrgb(0, 255, 255)#00FFFF
Tealrgb(0, 128, 128)#008080
Bluergb(0, 0, 255)#0000FF
Navyrgb(0, 0, 128)#000080
Purplergb(128, 0, 128)#800080
Magentargb(255, 0, 255)#FF00FF
Pinkrgb(255, 192, 203)#FFC0CB
Brownrgb(165, 42, 42)#A52A2A
Grayrgb(128, 128, 128)#808080
Blackrgb(0, 0, 0)#000000
Whitergb(255, 255, 255)#FFFFFF

Frequently asked questions

Which case should I use for the letters in the result?

Either works in CSS, SVG and HTML, because a browser treats #FF5733 and #ff5733 as the same color. Pick one style for the project and enforce it with a linter or formatter so diffs and code searches stay consistent.

Can the HEX result be shortened to three digits?

Only when each pair consists of two identical digits. For example rgb(255, 136, 0) gives #ff8800, which shortens to #f80. A channel such as 87 is 57 in hex, so it has no short form. Shorthand is optional and the six-digit form is always valid.

Are HEX and RGB the same color model?

Yes, a HEX code is just a compact notation for the same red, green and blue channels. #FF5733 and rgb(255, 87, 51) describe exactly the same color, so the conversion is lossless in both directions.

What do the six characters in a HEX code mean?

They are three two-digit hexadecimal numbers: the first pair is red, the second green, the third blue. Each pair ranges from 00 (0) to FF (255). Three-digit shorthand like #F53 expands by doubling each digit (#FF5533).

Does HEX support transparency?

Yes, an eight-digit code #RRGGBBAA adds an alpha pair, where 00 is fully transparent and FF is fully opaque. In CSS you can also use the rgba() notation, e.g. rgba(255, 87, 51, 0.5).

More color converters

Need to grab a color from an image or screenshot? Try the free Pixel Color Picker →