HEX to RGB Converter

Paste any hex code, 3, 4, 6 or 8 digits, and get rgb() instantly, plus HSL, HWB and OKLCH. Alpha is preserved, everything runs locally, and every value has a one-click copy.

sRGB P3
Formats
Advanced spaces & developer export

Contrast checker

WCAG contrast applies to the final rendered colors. Transparent foregrounds and backgrounds are composited over the backdrop below, exactly like a browser renders them, before the ratio is calculated.

-
AA normal AA large AAA normal AAA large

AA needs 4.5:1 for normal text, 3:1 for large (24px, or 18.5px bold). AAA needs 7:1 and 4.5:1.

Tints, shades & harmonies

Generated in OKLCH (perceptually even lightness steps, constant hue) and gamut-mapped to sRGB. Click any swatch to copy its hex.

The hex-to-RGB cheat sheet

Reading hex without a converter is a party trick worth thirty seconds: the first pair is red, then green, then blue, each from 00 to FF. Memorize four anchors: 00 is 0, 40 is 64, 80 is 128, FF is 255, and you can estimate any color. #804000 reads as half red, quarter green, no blue: a brown. The converter above does the exact math, keeps alpha from 4 and 8-digit codes, and adds the modern formats a cheat sheet cannot: hwb(), oklch() and Display-P3, with gamut badges when a color will not survive the trip to sRGB.

HEX to RGB FAQ

How does HEX to RGB conversion work?

A hex code is three pairs of base-16 digits, one pair per channel: red, green, blue. Each pair maps to 0-255: FF is 255, 80 is 128, 00 is 0. So #FF6347 is rgb(255, 99, 71): FF=255, 63=99, 47=71. Shorthand 3-digit codes double each digit, so #F04 means #FF0044. The converter above does this instantly for any hex code and hands you rgb(), hsl(), hwb() and oklch() with copy buttons.

What about 4 and 8-digit hex codes?

The extra digit or pair is alpha, from 00 (fully transparent) to FF (opaque). #2563EB80 is that blue at just over 50% opacity and converts to rgb(37 99 235 / 0.5). This tool preserves alpha in every output format and, unlike most converters, its contrast checker composites that transparency correctly instead of ignoring it.

Why does my converted RGB look different in another program?

Usually a color-space mismatch, not a conversion error. HEX and rgb() encode sRGB; design tools set to Display-P3 or unmanaged monitors will show the same numbers differently. The gamut badges above tell you whether your color sits inside sRGB, and if you started from a wide-gamut value, how much the mapping to hex changed it.

Which direction should CSS prefer, hex or rgb()?

They encode identical colors, so it is style and tooling. Hex is compact and universal. Modern rgb() with slash alpha, rgb(37 99 235 / 50%), reads more clearly when transparency is involved. For new design systems, consider oklch() instead: perceptually uniform and now supported everywhere; this page outputs it alongside the classics.