HEX to RGB Converter
Type or paste a hex color code — #2D56A3, FFF, #3E2608FF, even 0xFF90BE6D — and get RGB, RGBA, HSL, HSV, CMYK and 0–1 values instantly.
Also accepts rgb(), hsl(), 0x… and color names. Press / to focus.
Learn
How to Convert HEX to RGB
A hex color code is just three numbers — red, green, blue — each written as two hexadecimal (base-16) digits. Converting to RGB means reading each pair as a normal decimal number from 0 to 255.
- Remove the
#.#2D56A3→2D56A3. For 3-digit shorthand, double each digit:#F80→FF8800. - Split into pairs. Red
2D, green56, blueA3. - Convert each pair. First digit × 16 + second digit, where A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
2D= 2 × 16 + 13 = 45 ·56= 5 × 16 + 6 = 86 ·A3= 10 × 16 + 3 = 163 - Write it as RGB.
#2D56A3=rgb(45, 86, 163).
Going the other way: RGB to HEX
Divide each channel by 16: the quotient is the first hex digit, the remainder the second. rgb(194, 66, 66) → 194 = 12×16 + 2 → C2, 66 = 4×16 + 2 → 42, giving #C24242. The dedicated RGB to HEX converter does this for you.
Alpha, 8-digit hex and other notations
An 8-digit code like #3E2608FF adds a fourth pair for alpha: divide it by 255 to get the RGBA alpha (FF → 1, 80 → 0.502). Programming languages often write hex with a 0x prefix, and Android/.NET put alpha first (0xAARRGGBB). All of these work in the converter. More in the RGBA & transparency guide and the CSS color formats reference.
In code
// JavaScript
const hexToRgb = hex => {
const n = parseInt(hex.replace('#', ''), 16);
return [n >> 16 & 255, n >> 8 & 255, n & 255];
};
hexToRgb('#2D56A3'); // [45, 86, 163]
# Python
def hex_to_rgb(h):
h = h.lstrip('#')
return tuple(int(h[i:i + 2], 16) for i in (0, 2, 4))
Reference
Common HEX to RGB Conversions
| HEX | RGB | HSL | RGB 0–1 |
|---|---|---|---|
| #000000 | rgb(0, 0, 0) | hsl(0, 0%, 0%) | 0, 0, 0 |
| #FFFFFF | rgb(255, 255, 255) | hsl(0, 0%, 100%) | 1, 1, 1 |
| #FF0000 | rgb(255, 0, 0) | hsl(0, 100%, 50%) | 1, 0, 0 |
| #00FF00 | rgb(0, 255, 0) | hsl(120, 100%, 50%) | 0, 1, 0 |
| #0000FF | rgb(0, 0, 255) | hsl(240, 100%, 50%) | 0, 0, 1 |
| #FFFF00 | rgb(255, 255, 0) | hsl(60, 100%, 50%) | 1, 1, 0 |
| #00FFFF | rgb(0, 255, 255) | hsl(180, 100%, 50%) | 0, 1, 1 |
| #FF00FF | rgb(255, 0, 255) | hsl(300, 100%, 50%) | 1, 0, 1 |
| #808080 | rgb(128, 128, 128) | hsl(0, 0%, 50%) | 0.502, 0.502, 0.502 |
| #C0C0C0 | rgb(192, 192, 192) | hsl(0, 0%, 75%) | 0.753, 0.753, 0.753 |
| #800000 | rgb(128, 0, 0) | hsl(0, 100%, 25%) | 0.502, 0, 0 |
| #008000 | rgb(0, 128, 0) | hsl(120, 100%, 25%) | 0, 0.502, 0 |
| #000080 | rgb(0, 0, 128) | hsl(240, 100%, 25%) | 0, 0, 0.502 |
| #800080 | rgb(128, 0, 128) | hsl(300, 100%, 25%) | 0.502, 0, 0.502 |
| #008080 | rgb(0, 128, 128) | hsl(180, 100%, 25%) | 0, 0.502, 0.502 |
| #FFA500 | rgb(255, 165, 0) | hsl(39, 100%, 50%) | 1, 0.647, 0 |
| #6C5CE7 | rgb(108, 92, 231) | hsl(247, 74%, 63%) | 0.424, 0.361, 0.906 |
| #2D56A3 | rgb(45, 86, 163) | hsl(219, 57%, 41%) | 0.176, 0.337, 0.639 |
| #304B78 | rgb(48, 75, 120) | hsl(218, 43%, 33%) | 0.188, 0.294, 0.471 |
| #007AC8 | rgb(0, 122, 200) | hsl(203, 100%, 39%) | 0, 0.478, 0.784 |
| #36C1D7 | rgb(54, 193, 215) | hsl(188, 67%, 53%) | 0.212, 0.757, 0.843 |
| #11FFAA | rgb(17, 255, 170) | hsl(159, 100%, 53%) | 0.067, 1, 0.667 |
| #5E2F26 | rgb(94, 47, 38) | hsl(10, 42%, 26%) | 0.369, 0.184, 0.149 |
| #8C9099 | rgb(140, 144, 153) | hsl(222, 6%, 57%) | 0.549, 0.565, 0.6 |
Generate
Color Palette Generator
Click any swatch to copy its HEX value. Pick a scheme or let it surprise you — or build a palette around the color in the converter. New to harmony schemes? Read the color harmony guide.
Accessibility
WCAG Contrast Checker
Enter text and background colors (hex, rgb() or names) to check WCAG 2.x compliance. For thresholds and edge cases, read the WCAG color contrast guide.
Reference
CSS Named Colors
All 140 distinct CSS named colors. Click to load one into the converter; Ctrl/⌘-click (or browse the color index) for shades, tints and contrast data.
FAQ
Frequently Asked Questions
0x is a programming prefix for hexadecimal. In Android and .NET an 8-digit 0x color is ARGB, so 0xFF90BE6D is alpha FF (opaque) followed by #90BE6D = rgb(144, 190, 109). Paste it into the converter and it is read as ARGB automatically.const n = parseInt('2D56A3', 16); const rgb = [n >> 16 & 255, n >> 8 & 255, n & 255]; In Python: tuple(int('2D56A3'[i:i+2], 16) for i in (0, 2, 4)) returns (45, 86, 163).255, 87, 51, and CSS names like tomato. Every format is converted to all the others.Read
In-Depth Guides
RGB to HEX Converter
Turn rgb(), rgba() or plain 0–255 values into a hex code, with the divide-by-16 method explained.
HSL Color Explained
Hue, saturation, lightness — the hue wheel, HSL to RGB math, and HSL vs HSV.
RGBA & Transparency
How alpha composites, RGBA vs 8-digit hex, an alpha-to-hex table and the opacity gotchas.
WCAG Contrast Guide
AA vs AAA, large vs normal text, the luminance formula, and the edge cases the rule leaves room for.
Color Harmony Schemes
Monochromatic, analogous, complementary, split, triadic, tetradic — what each feels like and when it fits.
CSS Color Formats
Hex, rgb, hsl, hwb, lab, lch, oklch, color() — plus 0x, ARGB and 0–1 notations outside CSS.