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.
- RGB
rgb(183, 54, 203) - HSL
hsl(292, 59%, 50%) - CMYK
cmyk(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.
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
Related guides
Frequently asked questions
Is #FFF the same as #FFFFFF?
How do I convert a hex color like #B736CB to RGB values?
What's the difference between #RGB and #RRGGBB hex notation?
Does the converter need the # sign?
Related tools
Contrast Checker
Check color contrast ratios for WCAG AA/AAA accessibility compliance.
Use toolJSON Formatter
Validate, format, and minify JSON. Browse it as a tree, run JSONPath queries, compare two documents, or validate against a JSON Schema.
Use toolAspect Ratio Visualizer
Visually compare width differences between 16:9, 21:9, and 32:9 monitors.
Use tool