RGB to HEX and HEX to RGB Color Converter
By TheToolsBank Editorial TeamLast updated:
How to convert RGB to HEX or HEX to RGB
- Pick a direction: RGB → HEX (the default) or HEX → RGB.
- In RGB mode, type a number from 0 to 255 in each of the R, G and B boxes. In HEX mode, type a code such as
#3B82F6or3AF. - Or drag in the color square and hue bar to choose a color visually.
- Read the HEX, RGB, HSL and CMYK results on the right. Click a row to copy that value.
The results change as soon as you type. If a HEX code is not valid, the tool shows a message and hides the results until the code is fixed.
Common colors in HEX, RGB, HSL and CMYK
| Color | HEX | RGB | HSL | CMYK |
|---|---|---|---|---|
| Blue (tool default) | #3B82F6 | rgb(59, 130, 246) | hsl(217, 91%, 60%) | cmyk(76%, 47%, 0%, 4%) |
| Red | #FF0000 | rgb(255, 0, 0) | hsl(0, 100%, 50%) | cmyk(0%, 100%, 100%, 0%) |
| Orange | #FFA500 | rgb(255, 165, 0) | hsl(39, 100%, 50%) | cmyk(0%, 35%, 100%, 0%) |
| Green | #22C55E | rgb(34, 197, 94) | hsl(142, 71%, 45%) | cmyk(83%, 0%, 52%, 23%) |
| Gray | #808080 | rgb(128, 128, 128) | hsl(0, 0%, 50%) | cmyk(0%, 0%, 0%, 50%) |
| White | #FFFFFF | rgb(255, 255, 255) | hsl(0, 0%, 100%) | cmyk(0%, 0%, 0%, 0%) |
| Black | #000000 | rgb(0, 0, 0) | hsl(0, 0%, 0%) | cmyk(0%, 0%, 0%, 100%) |
These are the exact values the tool shows. HSL and CMYK are rounded to whole numbers.
How the HEX to RGB math works
A HEX color is three pairs of base-16 digits: red, green, then blue. Each pair runs from 00 (0) to FF (255). To convert a pair, multiply the first digit by 16 and add the second, where A to F stand for 10 to 15.
Take #3B82F6. 3B is 3 × 16 + 11 = 59. 82 is 8 × 16 + 2 = 130. F6 is 15 × 16 + 6 = 246. So the color is rgb(59, 130, 246). RGB to HEX is the same steps in reverse: 246 ÷ 16 is 15 remainder 6, which is F6.
A 3-digit code doubles each digit. #3AF means #33AAFF, which is rgb(51, 170, 255).
Accepted input and limits
- HEX input accepts 3 or 6 hex digits, with or without the leading #. Upper and lower case both work, and spaces around the code are ignored.
- HEX output is always 6 digits in uppercase, such as #33AAFF.
- RGB boxes take whole numbers. Values above 255 become 255, negative values become 0, and decimals are cut to the whole number.
- Alpha is not supported. 8-digit codes like #3B82F680 and rgba() values are rejected or ignored.
- You cannot paste a full rgb(59, 130, 246) string. Type the three numbers into the separate boxes.
Which format to use
Use HEX in CSS, HTML and most design apps; it is short and easy to copy. Use RGB when code or software asks for separate red, green and blue numbers. Use HSL when you want to adjust a color by hand, because changing the last number makes it lighter or darker without changing the hue.
The CMYK figures are a simple math conversion, not a printer color profile. Ask your print shop for exact values. To find a color in a photo, use the Image Color Picker. To see what a code is called, try the Color Name Finder.
Common Mistakes to Avoid
Pasting an 8-digit HEX code with transparency.
Solution:
Typing a 5-digit or 4-digit code.
Solution:
Mixing up the letter O and the number 0.
Solution:
Treating the CMYK result as print-ready.
Solution:

