What Is a Hex to RGB Converter?
Hexadecimal colour codes (#RRGGBB) store each sRGB channel as two hex digits. A hex to RGB converter expands that into 0–255 red, green, and blue values for CSS, design tools, and code. This page also outputs RGBA (with opacity), HSL, HSV, CMYK, and a live swatch.
Hex to RGB Formula
Split #RRGGBB into pairs and parse each as base 16. Three-digit shorthand #RGB expands by doubling every digit.
R = int(RR, 16) # 0–255
G = int(GG, 16)
B = int(BB, 16)
# Shorthand #RGB expands to #RRGGBB (each digit doubled).HSL, CMYK, and WCAG Contrast
HSL is handy for adjusting lightness in CSS. CMYK estimates print-style channels from sRGB (approximate, not ICC-managed). Contrast ratios against white and black use relative luminance as a quick WCAG check— always verify in context, including for colour blindness.
Hex to RGB FAQs
- How do I convert hex to RGB?
- Take a hexadecimal colour code such as #3ECF8E, split it into RR, GG, and BB pairs, then convert each pair from base 16 to a 0–255 channel. This hex to RGB converter also expands three-digit shorthand and shows RGBA, HSL, HSV, and CMYK.
- What is the hex to RGB formula?
- For #RRGGBB, R = parseInt(RR, 16), G = parseInt(GG, 16), B = parseInt(BB, 16). Shorthand #RGB doubles each digit to #RRGGBB before converting. Optional AA adds an alpha channel for RGBA.
- Can I convert RGB back to hex?
- Yes. Enter R, G, and B (0–255) and optional opacity to get a hex colour code and CSS values. That covers rgb hex to RGB workflows in either direction.
- Does this include HSL and CMYK?
- Yes. After hex to RGB conversion you get HSL, HSV, and CMYK percentages plus a live swatch in the sRGB colour space used by CSS.
- How do I convert hex to RGB in JavaScript or Python?
- In JS use parseInt(hex.slice(1, 3), 16) for each pair (or this page’s snippets). In Python use int(hex[0:2], 16). The tool is for quick checks without writing a script.
- What about WCAG contrast?
- The tool shows approximate contrast ratios against white and black using relative luminance. Use them as a starting point for WCAG checks; always verify in your full UI.
