RGB to HEX Converter

Convert RGB to HEX instantly

Enter colors Red, Green, and Blue and get a matching HEX color code instantaneously β€” you can preview it and be sure you're getting the color you want. Move the sliders or enter the values 0 - 255 for each channel. The hex code will update in real-time and it can be copied to your clipboard in one click.

RGB Input Channels

RED (R) 15
GREEN (G) 23
BLUE (B) 42
ALPHA / OPACITY 1.00

RGB to HEX Convertor: What is RGB to HEX conversion?

RGB and HEX are two ways of writing the same colorβ€”there's no change in the color itself; just how it's written in code.

RGB refers to a colour as three numbers: Red, Green, Blue – each one varying from 0 to 255 indicating the amount of light of that colour that is added in. It is the default mode of most photo-editing programs (Photoshop, Figma, Illustrator) and is intuitive because you can view each channel individually.

HEX does the same, but writes those three numbers as a single 6 character code, in base-16 (hexadecimal), preceded by a # β€” rgb(220, 54, 54) is written as #DC3636. It is the way that most stylesheets use it when writing CSS and HTML, and requires less space than rgb() each time.

They both display the same color, just a notation convention change β€” not a color change.

Process of the conversion.

Each channel (0–255) is represented as a 2-digit hex number, then the three pairs are concatenated:

  1. Convert the Red value into a two digit (00 – FF) hex number.
  2. Convert the Green value into two hex digits (00 - FF)
  3. Change the Blue value to 2 hex digits (00 to FF)
  4. Add a # at the beginning and join them up, #RRGGBB

Example: rgb(220, 54, 54) β†’
220 in hex = DC
54 in hex = 36
54 in hex = 36 β†’ #DC3636

The range of each hex digit is 0-9 then A-F so 2 digits can represent 0-255 exactly (16 x 16 = 256 possible values per channel) and HEX and RGB colors can always convert back and forth without loss of precision.

Common Color Conversions (Reference Table)

Color RGB HEX
Black rgb(0, 0, 0) #000000
White rgb(255, 255, 255) #FFFFFF
Red rgb(255, 0, 0) #FF0000
Green rgb(0, 128, 0) #008000
Blue rgb(0, 0, 255) #0000FF
Yellow rgb(255, 255, 0) #FFFF00
Gray rgb(128, 128, 128) #808080
Orange rgb(255, 165, 0) #FFA500

Hex to RGBA: Transparency Issues

The standard six-digit hex color notation doesn't have a transparent component, so if your color has transparency (alpha) value, like rgba(220, 54, 54, 0.5), it won't work. There are 2 ways to deal with it:

  • Modern CSS also adds a 4th pair of digits to the hex to handle transparency, #DC363680 and the last 2 digits are the transparency - 00 is transparent, FF is opaque. It is well supported by the current versions of Chrome, Firefox, Safari, and Edge, but may not be recognised by older versions of browsers.
  • If you want a guaranteed compatibility, then don't convert the color, it will be rgba() instead of HEX8.

Three-Digit HEX Shorthand

When all three pairs of channels are the same, a shortened 3 digit hex code can be used in the CSS, for example #33ff99 can be shortened to #3f9. It will only work if the two digits in each pair are the same (e.g. #DC3636 cannot be shortened because DC is not a repeated digit). The hex form is always valid, and is the default output of any RGB-to-HEX conversion, while the three-digit form is a short-hand that only works for a limited number of colors.

The time to use RGB vs. HEX.

Use RGB when... Use HEX when...
You're using design software to make adjustments to colors. You are writing CSS, HTML or the most styling of the web.
You have to use transparency (using RGBA). You'd like a shorter and compact code.
You are using an RGB canvas/graphics API You are copying a brand colour from a style guide (most will provide HEX).

In reality, most designers will be working in RGB when creating their designs, and only switch to HEX when it's time to pass it off to the developer or to compile it into CSS β€” that's when this is needed.

Frequently Asked Questions

Does it change the real color when you convert from RGB to HEX?

RGB and HEX are only two different ways of spelling the same color – changing one type of notation into another does not change the color, only the way it is written.

Why is the majority of the time CSS uses HEX rather than RGB?

They both work in current CSS, but because of its smaller size (#DC3636 vs rgb(220, 54, 54)) and since it was the initial format supported by early browsers, most style guides and design tools and brand kits adopted HEX.

How to get RGB back from HEX?

Yes β€” reverse the conversion, split the hex number into three two-digit quantities and convert each two-digit quantity from base-16 to base-10 (decimal).

What do all of the Rs, Gs and Bs represent?

Three numbers (Red, Green, Blue) are each a measure of the strength (or intensity) of the light of that colour, ranging from 0 (no light) to 255 (full strength). All three at highest setting = white, all three at lowest setting = black.

Are the difference between HEX and HTML color names ("red" or "tomato")?

Yes, there are about 140 named colors, but they are a limited subset of colors that are hard-coded into HTML. All the colors are actually HEX codes and named colors are simply shortcuts for certain HEX codes.

Why do some HEX codes have 8 digits instead of 6?

An 8-digit HEX code (HEX8) adds two extra digits at the end to represent alpha transparency, functioning the same way RGBA does. Standard 6-digit HEX has no transparency channel β€” it's fully opaque by definition.

Is HEX case-sensitive?

No. #DC3636 and #dc3636 refer to the exact same color β€” HEX letters (A–F) can be uppercase or lowercase interchangeably in CSS and HTML.

Share This Tool

Browser Extension

Get quick access to remove the gemini watermark from the image and video directly from your browser toolbar.