HEX to RGB Converter

HEX to RGB Converter changes a HEX color code into RGB values in seconds. Enter your color, get Red, Green, and Blue values, copy the result, and use it in CSS or design tools.
Input format
HEX#6366F1
RGBrgb(99, 102, 241)
HSLhsl(239, 84%, 67%)
Recent
Nothing here yetYour recent activity will appear here

What Is a HEX Color Code?

A HEX color code uses hexadecimal numbers to describe a color. A six digit HEX code uses three pairs for Red, Green, and Blue. For example, #FF5733 uses FF for Red, 57 for Green, and 33 for Blue. The code can start with #, but converters can accept the characters without it.

What Is RGB?

RGB stands for Red, Green, and Blue. It describes a color with three channel values, usually from 0 to 255. Each channel controls one part of the final color.

Red

The Red channel controls how much red appears in an RGB color. Its value ranges from 0 to 255. A value of 0 adds no red, while 255 adds the strongest red. For example, FF in HEX equals 255, producing maximum red.

Green

The Green channel controls the green part of an RGB color. Its value ranges from 0 to 255. Higher values add more green, while 0 adds none. For example, 80 in HEX equals 128 in decimal, creating a medium green level.

Blue

The Blue channel controls the blue part of an RGB color. Its value ranges from 0 to 255. A value of 255 gives the strongest blue, while 0 adds none. For example, 00 in HEX equals 0 in decimal, so it adds no blue.

HEX to RGB Converter tool for converting HEX color codes into RGB values

How can you use our HEX to RGB Converter?

Our HEX to RGB Converter quickly converts HEX color codes into RGB values.

Step 1

Enter Your HEX Color

Type or paste a HEX color code into the converter.

Step 2

View RGB Result

Get the RGB value instantly from your HEX color.

Step 3

Copy Result

Copy the converted RGB value for future use.

HEX to RGB Conversion

HEX to RGB conversion changes hexadecimal color pairs into decimal RGB values. A six digit HEX code contains three pairs: Red, Green, and Blue. Each pair ranges from 00 to FF in HEX and becomes 0 to 255 in RGB. For example, FF5733FF5733 becomes rgb(255,87,51)rgb(255, 87, 51). The first pair controls Red, the second controls Green, and the third controls Blue. You can then place the three decimal values inside the CSS rgb()rgb() format.

Formula

R=HEXRRR = HEX_{RR}, G=HEXGGG = HEX_{GG}, and B=HEXBBB = HEX_{BB}.

Each HEX pair changes from base 16 to a decimal value from 0 to 255.

Decimal=(first digit×16)+second digitDecimal = (first\ digit × 16) + second\ digit

Step 1: Convert HEX to RGB Components

Remove the optional # symbol. Read the six HEX characters as three pairs. The first pair is Red, the second is Green, and the third is Blue.

Step 2: Convert Each HEX Pair to Decimal

Change each pair from hexadecimal to decimal. Remember that A equals 10, B equals 11, through F equals 15.

Step 3: Determine the Red Value

Read the first HEX pair. For FFFF, calculate (15×16)+15=255(15 × 16) + 15 = 255. Therefore, the Red value becomes 255.

Step 4: Determine the Green Value

Read the second HEX pair. For 5757, calculate (5×16)+7=87(5 × 16) + 7 = 87. Therefore, the Green value becomes 87.

Step 5: Determine the Blue Value

Read the third HEX pair. For 3333, calculate (3×16)+3=51(3 × 16) + 3 = 51. Therefore, the Blue value becomes 51.

Step 6: Format the RGB Value

Place the three decimal values in RGB order. For #FF5733, use rgb(255,87,51)rgb(255, 87, 51). The color remains the same.

Example: Convert HEX to RGB

For HEX = #FF5733, the pairs are FFFF, 5757, and 3333. They become 255, 87, and 51. The final result is RGB=rgb(255,87,51)RGB = rgb(255, 87, 51).

[Word Count: 230 | LSI Terms Used: 14 | PAA Answered: Yes]

HEX to RGB Conversion Table

Color

HEX Code

Red

Green

Blue

RGB Value

Black

#000000

0

0

0

rgb(0, 0, 0)

White

#FFFFFF

255

255

255

rgb(255, 255, 255)

Red

#FF0000

255

0

0

rgb(255, 0, 0)

Green

#00FF00

0

255

0

rgb(0, 255, 0)

Blue

#0000FF

0

0

255

rgb(0, 0, 255)

Yellow

#FFFF00

255

255

0

rgb(255, 255, 0)

Cyan

#00FFFF

0

255

255

rgb(0, 255, 255)

Magenta

#FF00FF

255

0

255

rgb(255, 0, 255)

Gray

#808080

128

128

128

rgb(128, 128, 128)

Note: HEX uses hexadecimal pairs from 00 to FF. RGB uses decimal channel values from 0 to 255 for Red, Green, and Blue. The conversion keeps the same color.

How to Convert HEX to RGB Programmatically

HEX to RGB Using C#

The following C# function converts a standard six digit HEX code into an RGB value. It removes the # symbol and reads each channel separately.


string HexToRgb(string hexCode)
{
string hex = hexCode.TrimStart('#');

if (hex.Length != 6)
throw new ArgumentException("HEX code must contain 6 digits.");

int red = Convert.ToInt32(hex.Substring(0, 2), 16);
int green = Convert.ToInt32(hex.Substring(2, 2), 16);
int blue = Convert.ToInt32(hex.Substring(4, 2), 16);

return $"rgb({red}, {green}, {blue})";
}

For example, #FF5733 returns rgb(255, 87, 51).

HEX to RGB Using JavaScript

JavaScript can convert each HEX pair with parseInt() and base 16. This approach works well for browser tools and web applications.


function hexToRgb(hexCode) {
const hex = hexCode.replace("#", "");

if (hex.length !== 6) {
throw new Error("HEX code must contain 6 digits.");
}

const red = parseInt(hex.slice(0, 2), 16);
const green = parseInt(hex.slice(2, 4), 16);
const blue = parseInt(hex.slice(4, 6), 16);

return rgb(${red}, ${green}, ${blue});
}

For example, #3366FF returns rgb(51, 102, 255).

HEX to RGB Use Cases

Use the HEX to RGB Converter for web pages, CSS styles, UI design, graphics, design systems, and color palettes. Get ready to use RGB values quickly.

Web Development

Convert HEX colors into RGB values for websites, HTML elements, SVG graphics, and front end design work. This helps keep color code consistent.

CSS Color Styling

Turn HEX codes into RGB or RGBA values for CSS color styling. Use the result for text, backgrounds, borders, and UI elements without manual conversion.

UI and UX Design

Designers can convert HEX colors to RGB values when matching colors across Figma, interfaces, buttons, icons, and UI elements. This keeps colors aligned.

Graphic Design

Convert color codes for digital graphics, layouts, illustrations, and image work when a design tool needs RGB values. The result gives clear RGB channels.

Design Systems

Keep colors consistent across a design system by storing HEX and RGB values for shared components, states, and brand colors. This supports consistency.

Color Palette Generation

Convert palette colors into RGB values for design tools, CSS files, color libraries, and reusable visual styles. This makes color sharing easier.

Explore more Color Converters

Explore more Color Converters to transform HEX, RGB, and HSL values quickly for CSS, web design, and creative projects.

HEX to HSL Converter HSL to HEX Converter

HSL to RGB Converter RGB to HEX Converter RGB to HSL Converter

Frequently Asked Questions

These FAQs explain HEX inputs, RGB values, alpha, CSS use, accepted formats, accuracy, errors, and free developer use.