Skip to content

Hex to RGB Converter

Convert hexadecimal color codes to RGB values instantly. Supports shorthand and 8-digit hex with alpha.

Hex to RGB Converter tool

Loading...

Example

Input: #C4653A

Result: RGB: rgb(196, 101, 58), HSL: hsl(19, 54%, 50%)

Each pair of hex digits is one channel in base 16: C4 = 196 red, 65 = 101 green and 3A = 58 blue. The HSL value is derived from those three channels.

Common Hex Colors and Their RGB Values

ColorHexRGB
Black#000000rgb(0, 0, 0)
White#FFFFFFrgb(255, 255, 255)
Red#FF0000rgb(255, 0, 0)
Lime (pure green)#00FF00rgb(0, 255, 0)
Blue#0000FFrgb(0, 0, 255)
Yellow#FFFF00rgb(255, 255, 0)
Cyan#00FFFFrgb(0, 255, 255)
Magenta#FF00FFrgb(255, 0, 255)
Gray#808080rgb(128, 128, 128)
Silver#C0C0C0rgb(192, 192, 192)
Orange#FFA500rgb(255, 165, 0)
Navy#000080rgb(0, 0, 128)

Computed with the converter. Names follow the CSS named colors.

  1. Enter a hexadecimal color code in the input field, with or without the # prefix.
  2. The tool accepts 3-digit shorthand (e.g., #F00), standard 6-digit (e.g., #FF5733), and 8-digit hex codes with alpha (e.g., #FF573380).
  3. View the converted red, green, and blue channel values (each 0-255) displayed instantly below the input.
  4. If you entered an 8-digit hex code, check the alpha transparency value shown as a decimal between 0 and 1.
  5. Click the copy button next to the RGB output to copy it in CSS-ready rgb() format for your stylesheet.

How Hex Color Codes Map to RGB

A hex color code is three numbers written in base 16. #C4653A splits into C4, 65 and 3A, which are 196 red, 101 green and 58 blue, so it equals rgb(196, 101, 58). This converter does the split for you and also gives the HSL version.

Each pair of hex digits runs from 00 to FF, which is 0 to 255 in everyday numbers. The letters A to F stand for 10 to 15. To decode a pair by hand, multiply the first digit by 16 and add the second: C4 is 12 x 16 + 4 = 196. Three channels with 256 levels each give about 16.7 million colors.

The tool reads four lengths of code. Three digits, such as #F60, is shorthand where each digit is doubled, so it means #FF6600. Six digits is the standard form. Four and eight digits add an alpha pair for transparency. You then get rgba() and hsla() output, with alpha as a decimal from 0 to 1.

You can also drag the red, green and blue sliders and watch the hex code change. If you do not know the code yet, the Color Picker lets you choose by eye. The Color Name Finder tells you the nearest CSS color name for any code.

Formula / How It Works

R = parseInt(hex[1..2], 16), G = parseInt(hex[3..4], 16), B = parseInt(hex[5..6], 16). For shorthand, each digit is doubled before conversion.

Sources

Frequently Asked Questions

Split the six digits into three pairs and convert each pair from base 16. Multiply the first digit by 16 and add the second, counting A as 10 up to F as 15. For #3A99C4, 3A is 3 x 16 + 10 = 58, 99 is 9 x 16 + 9 = 153, and C4 is 196. The result is rgb(58, 153, 196).
It is shorthand. Each digit is written twice, so #F00 becomes #FF0000, which is pure red, rgb(255, 0, 0). Only colors made of doubled digits have a short form. #336699 can be written #369, but #C4653A has no shorter version.
The last two digits set the alpha, or opacity. 00 is fully transparent and FF is fully solid. #C4653A80 is the same orange at about half opacity, because 80 in hex is 128, and 128 / 255 is 0.502. This tool shows it as rgba(196, 101, 58, 0.502). A 4-digit code such as #F008 works the same way in short form.
No. #c4653a, #C4653A and #C4653a are the same color, and CSS and design apps treat upper and lower case alike. This tool shows its hex output in upper case, which makes codes easier to compare at a glance.
Both give exactly the same color, so it is mostly a matter of style. Hex is shorter and common in design handoffs. rgb() is easier to read and tweak by hand, and modern CSS lets you add alpha with a slash, as in rgb(196 101 58 / 50%). Pick one format and use it across the project.

Related Tools

RGB to HSL Converter

Convert RGB color values to HSL format. See hue, saturation, and lightness with a live color preview.

Color Tools

HSL to Hex Converter

Convert HSL color values to hexadecimal codes. Enter hue, saturation, and lightness for instant hex output.

Color Tools

Color Picker

Pick any color visually and get values in hex, RGB, HSL, and CMYK. Interactive saturation panel and hue slider.

Color Tools

Color Name Finder

Find the closest named CSS color for any hex color code. Identify colors by their standard names instantly.

Color Tools

Color Shade and Tint Generator

Generate shades and tints of any color. Create darker and lighter variations for complete color scales.

Color Tools

Random Color Generator

Generate random colors in HEX, RGB, and HSL formats. Create palettes and copy color codes instantly.

Randomizers and Generators