Convert a hex color code to RGB values

By TechCompare · Updated · How we check

Each pair of hex digits is one RGB channel, a base 16 number from 0 to 255. #B736CB becomes rgb(183, 54, 203). The converter above does it as you type and also shows HSL and CMYK.

  • RGBrgb(183, 54, 203)
  • HSLhsl(292, 59%, 50%)
  • CMYKcmyk(10%, 73%, 0%, 20%)

A hex color code is three RGB numbers written in base 16. In #B736CB, the first two digits are red (B7 is 183), the middle two are green (36 is 54) and the last two are blue (CB is 203). That gives rgb(183, 54, 203). Paste your own code into the converter above to get RGB, HSL and CMYK in one go.

Conversion
HEX to RGB
Example: #B736CB
Category
Web Formats
Color knowledge base

How this is calculated

HTML 3.2 specified hexadecimal RGB values for several color-related attributes. That documents HTML support, but doesn't establish that the notation originated then. The format is case-insensitive (#b736cb = #B736CB) and supports shorthand when each channel uses identical hex digits (#FFF = #FFFFFF). Six-digit #RRGGBB represents opaque RGB, while CSS also supports four-digit #RGBA and eight-digit #RRGGBBAA forms when you need an alpha channel.

To convert by hand, split the code into three pairs and read each pair as a base 16 number. The digits A to F stand for 10 to 15, and the first digit of a pair counts 16 times its value. Take #B736CB: its red pair B7 is 11 × 16 + 7, which is 183. Every pair lands between 0 (00) and 255 (FF), the range of one 8-bit channel.

The HSL and CMYK rows come from the same RGB numbers, rounded to whole numbers. Turning hsl(292, 59%, 50%) back into hex gives #B734CB instead of #B736CB, because the rounding drops a little detail. Keep the hex code as your source of truth. CMYK comes from a plain formula with no ink or paper profile, so a print shop's own profile can give other numbers for the same color.

Verdict

Use hex for opaque colors you copy between design tools and code. Two hex characters map straight to one 0-255 integer per RGB channel: B7 becomes 183, 36 becomes 54, CB becomes 203, giving rgb(183, 54, 203). That one to one byte per channel structure makes hex to RGB lossless in both directions.

The three-digit shorthand (#FFF for #FFFFFF) doubles each RGB digit. The eight-digit form (#B736CBCC) adds the alpha byte, while the four-digit #RGBA form provides the same channels in shorthand. Use it, or rgba(), when you need transparency.

More Color scenarios

RGB vs CMYK
Screens add light and print adds ink. See one color in both, and why a plain CMYK formula can't promise a print match.
View details
HSL color model
Hue, saturation and lightness, with three live sliders and a table of common colors in hex, RGB and HSL.
View details
OKLCH in CSS
OKLCH (Lightness, Chroma, Hue) is a modern color space designed to be perceptually uniform, meaning that the same numerical change in a value produces roughly the same perceived change in color, regardless of the hue.
View details

Frequently asked questions

Is #FFF the same as #FFFFFF?
Yes for the three-digit RGB shorthand. CSS expands #FFF to #FFFFFF and #F00 to #FF0000 by doubling each RGB digit. CSS also supports four-digit #RGBA shorthand, which doubles the RGB and alpha digits, plus six- and eight-digit full forms.
How do I convert a hex color like #B736CB to RGB values?
Split the hex string into three two-character pairs: B7, 36, CB. Convert each pair from base 16 to decimal: 0xB7 = 183, 0x36 = 54, 0xCB = 203. The result is rgb(183, 54, 203). Browser DevTools and most design tools show the RGB values when you paste a hex code.
What's the difference between #RGB and #RRGGBB hex notation?
Three-digit hex (#F00) doubles each RGB digit to produce #FF0000. Six-digit hex (#FF0000) lets you specify any value from 0-255 per channel. CSS also supports four-digit #RGBA shorthand and eight-digit #RRGGBBAA, with the final digit or pair controlling alpha opacity.
Does the converter need the # sign?
No. It reads three or six hex digits with or without the #, in upper or lower case, so b736cb, #B736CB and #B3C all work. Anything else shows an error under the field. It doesn't read eight-digit codes, so drop the last two digits, which are the alpha, to convert the color itself.