RGB to HEX Converter

Convert an RGB color to HEX instantly. Enter red, green, and blue values from 0 to 255 to get the corresponding 6-digit HEX color code, with a live color preview and CSS-ready output.

RGB to HEX converter tool

RGB → HEX
RGB color
HEX value
#2563EB
R: 37 · G: 99 · B: 235

How to Convert RGB to HEX

RGB and HEX are two different ways of representing the same color. RGB uses three decimal values for red, green, and blue, while HEX uses six hexadecimal characters to represent those same three color channels.

To convert an RGB color to HEX, convert each RGB value from decimal (base 10) to hexadecimal (base 16), make sure each result contains exactly two characters, and then combine the three values after a # symbol.

For example, the RGB color rgb(37, 99, 235) converts to:

37 → 25, 99 → 63, 235 → EB

Therefore: rgb(37, 99, 235) → #2563EB

RGB to HEX Examples

Here are some common RGB colors and their corresponding HEX values.

Colour name RGB value Hex code
Black rgb(0, 0, 0) #000000
White rgb(255, 255, 255) #FFFFFF
Red rgb(255, 0, 0) #FF0000
Green rgb(0, 128, 0) #008000
Navy rgb(0, 0, 128) #000080
Yellow rgb(255, 255, 0) #FFFF00
Purple rgb(128, 0, 128) #800080
Blue rgb(37, 99, 235) #2563EB

RGB to HEX Formula

An RGB color contains three channels: red, green, and blue. Each channel can have a value from 0 to 255. HEX represents each channel using two hexadecimal digits, from 00 to FF.

The conversion can therefore be written as:

RGB(R, G, B) → #RR GG BB

Each decimal RGB value is converted separately to hexadecimal. For example, decimal 255 becomes hexadecimal FF, while decimal 0 becomes 00.

What Is an RGB Color?

RGB stands for Red, Green, Blue. It is an additive color model commonly used for screens and digital graphics. Each channel has a value from 0 to 255, giving 256 possible values for each of the three channels.

A color such as rgb(255, 0, 0) contains full red with no green or blue, producing pure red. rgb(0, 0, 0) is black, while rgb(255, 255, 255) is white.

What Is a HEX Color Code?

A HEX color code is a hexadecimal representation of an RGB color. A standard 6-digit HEX code contains three pairs of characters: one pair for red, one for green, and one for blue.

For example, #2563EB contains the three channel values 25, 63, and EB. These correspond to the RGB values 37, 99, and 235.

HEX color codes are commonly used in HTML and CSS. For example:

color: #2563EB;

Can RGB Be Converted to a 3-Digit HEX Code?

Sometimes. A 6-digit HEX code can be shortened to 3 digits when both characters in every channel pair are identical. For example, #AABBCC can be written as #ABC.

Not every RGB color has a 3-digit equivalent. This converter uses the full 6-digit HEX format so that every RGB value has an unambiguous output.

Related Color Tools

If you work with different color formats, you can convert between several common color models:

Color Palettes

Frequently asked questions

How do I convert RGB to HEX?

Convert each of the three RGB values from decimal to hexadecimal, using two hexadecimal characters for each channel, then combine them after a # symbol. For example, rgb(37, 99, 235) becomes #2563EB.

What is RGB color in HEX?

RGB color in HEX is the same color represented using hexadecimal notation instead of three decimal RGB values. For example, rgb(255, 0, 0) is #FF0000 in HEX.

What is the HEX code for RGB 255, 255, 255?

RGB 255, 255, 255 converts to the HEX color #FFFFFF, which represents white.

What is the HEX code for RGB 0, 0, 0?

RGB 0, 0, 0 converts to #000000, which represents black.

Can RGB values be decimals?

This converter uses RGB channel values from 0 to 255 and produces standard 6-digit HEX color codes. For typical RGB-to-HEX conversion, use integer channel values such as 37, 99, and 235.