Hex to RGB Converter: HEX, RGB and HSL Color Codes
This hex to RGB converter changes color codes between HEX, RGB and HSL instantly. Type a hex code like #2B6CB0, an RGB value or HSL, or pick a color visually, and all the other formats update. It also checks the WCAG contrast ratio of white and black text on your color, so you can choose readable combinations.
Everything runs in your browser. Nothing you enter is sent to or stored on our server.
Quick answer: A hex color is three pairs of hexadecimal digits for red, green and blue. Convert each pair to decimal: #2B6CB0 is 2B = 43, 6C = 108 and B0 = 176, so rgb(43, 108, 176). Type any code above to convert it instantly.
How to convert hex to RGB
- Remove the # and split the code into three pairs: 2B, 6C, B0.
- Convert each pair from base 16: multiply the first digit by 16 and add the second. A to F stand for 10 to 15, so 2B = 2 × 16 + 11 = 43.
- Write the result as rgb(43, 108, 176).
Short hex codes double each digit: #FA0 is the same as #FFAA00. To go from RGB to hex, convert each number to two hex digits and join them.
HEX, RGB and HSL explained
| Format | Example | Best for |
|---|---|---|
| HEX | #2B6CB0 | CSS, design tools and brand guides; compact and easy to copy. |
| RGB | rgb(43, 108, 176) | Screens and code that mixes red, green and blue light (0 to 255 each). |
| HSL | hsl(211, 61%, 43%) | Adjusting colors by hand: change lightness for tints and shades, or hue for a matching color. |
All three describe the same colors on screen. For print, designers convert to CMYK in their design software, which also accounts for paper and inks.
Contrast ratio and accessibility
The Web Content Accessibility Guidelines (WCAG) measure how readable text is against its background on a scale from 1:1 to 21:1. Normal text needs at least 4.5:1 for level AA and 7:1 for AAA; large text (about 24 px, or 19 px bold) needs 3:1. The boxes above show whether white or black text on your color passes. If neither passes well, darken or lighten the color using the HSL lightness value.
Common colors
| Color | HEX | RGB |
|---|---|---|
| White | #FFFFFF | 255, 255, 255 |
| Black | #000000 | 0, 0, 0 |
| Red | #FF0000 | 255, 0, 0 |
| Green (lime) | #00FF00 | 0, 255, 0 |
| Blue | #0000FF | 0, 0, 255 |
| Gray | #808080 | 128, 128, 128 |
Browse the full set of 216 classic web colors with our web safe colors chart, or check fonts with the web safe fonts list.
FAQ
What about 8-digit hex codes?
The last two digits are transparency (alpha). The converter reads the color and ignores the alpha.
Is hex case-sensitive?
No. #2b6cb0 and #2B6CB0 are the same color.
More free tools
See all of them on the QuickOnlineTips free online tools page and play our free online games.
