Skip to main contentAgent-Native Hackathon winners revealed live Nov 13.RSVP
CONTACT SALESSTART BUILDING

Hex to RGB converter

Turn any hex color code into its RGB value, with the matching HSL, OKLCH, CMYK and Tailwind values ready to use in your CSS.

3, 4, 6 or 8 digits. The # is optional.

RGB

White text3.22:1Fails AA

Black text6.52:1Passes AA

Other formats

Copy every format and code snippet in one click.

Free and open source

Got your color?Put it to work in your next design.

Agent-Native Design turns a prompt into ads, pages, brand assets and prototypes, all in your colors.

Hex to RGB in JavaScript and Python

// Reads 3, 4, 6 or 8 digits. The 4th pair, if any, is alpha const hexToRgb = (hex: string) => { let h = hex.replace("#", ""); if (h.length <= 4) h = [...h].map((c) => c + c).join(""); const [r, g, b, a = 255] = h.match(/../g)!.map((p) => parseInt(p, 16)); return { r, g, b, a: Math.round((a / 255) * 1000) / 1000 }; }; hexToRgb("#E2649A"); // { r: 226, g: 100, b: 154, a: 1 } hexToRgb("#E2649A80"); // { r: 226, g: 100, b: 154, a: 0.502 }

Common colors in hex and RGB

ColorHexRGB
White#FFFFFF255, 255, 255
Black#0000000, 0, 0
Red#FF0000255, 0, 0
Green#00FF000, 255, 0
Blue#0000FF0, 0, 255
Yellow#FFFF00255, 255, 0
Cyan#00FFFF0, 255, 255
Magenta#FF00FF255, 0, 255
Gray#808080128, 128, 128
Orange#FFA500255, 165, 0

FAQs

Get answers to common questions

Paste the hex code into the converter and copy the RGB values. To convert by hand, split the code into three pairs. Then convert each pair from base 16 to base 10. #E2649A splits into E2, 64 and 9A. In base 10 that's rgb(226, 100, 154).

They describe the same colors in two notations. RGB writes red, green and blue as numbers from 0 to 255. Hex writes the same numbers in base 16. #FF0000 and rgb(255, 0, 0) are the same red.

Use an 8-digit hex code. The last pair sets the opacity. #E2649A80 converts to rgba(226, 100, 154, 0.502). 80 in hex is 128, and 128 of 255 is about 50%.

Unity, Swift and shader code use decimals from 0 to 1 instead of 0 to 255. Divide each value by 255. 226 becomes 0.886. The converter shows both.

It's shorthand. Each digit is doubled. #E69 is the same as #EE6699. A 4-digit code like #E698 also sets the opacity.

It's another name for a hex to RGB converter. It reads a hex color code and shows the same color in other formats.

RGB to hexStart from red, green and blue values instead.