Skip to main content
CONTACT SALESSTART BUILDING

RGB to hex converter

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

rgb(), rgba() or plain numbers like 226 100 154.

Hex

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

Turn one color code intopages, ads and prototypes.

Agent-Native Design builds each one around your color, with readable text on every background.

TRY AGENT-NATIVE DESIGN

RGB to hex in JavaScript and Python

const toHex = (r: number, g: number, b: number) => "#" + [r, g, b].map((v) => v.toString(16).padStart(2, "0")).join(""); toHex(226, 100, 154); // "#e2649a"

Common colors in RGB and hex

ColorRGBHex
White255, 255, 255#FFFFFF
Black0, 0, 0#000000
Red255, 0, 0#FF0000
Green0, 255, 0#00FF00
Blue0, 0, 255#0000FF
Yellow255, 255, 0#FFFF00
Cyan0, 255, 255#00FFFF
Magenta255, 0, 255#FF00FF
Gray128, 128, 128#808080
Orange255, 165, 0#FFA500

More free color tools

Hex to RGBStart from a hex code instead.Image color pickerGet the HEX, RGB and HSL code of any color in a photo, plus its main colors as a palette.Color wheelBuild a palette from any color's harmonies and copy it as CSS or Tailwind.Color palette generatorCreate a palette in seconds, or build a light and dark theme from your brand color.Random color generatorGenerate random colors with names and hex, RGB or HSL codes, up to 10 at once.Inverted color wheelSee what your color becomes inverted.

FAQs

RGB to hex questions

Type the red, green and blue values into the converter and copy the hex code. To convert by hand, write each value from 0 to 255 as two base-16 digits. Then join the three pairs after a #.

Divide each channel by 16. The whole number is the first hex digit and the remainder is the second. Digits 10 to 15 are written A to F. Join red, green and blue in that order as #RRGGBB.

Set alpha below 100% and the converter adds a fourth pair. At 50%, #E2649A becomes #E2649A80. All current browsers support 8-digit hex in CSS.

FF is 255 in base 16. That's the highest value a channel can have. #FF0000 is full red with no green or blue.

Yes. RBG is a common typo for RGB. RGB stands for red, green and blue, always in that order. Hex codes use the same order.

A 6-digit hex code can show 16,777,216 colors. Each of the three channels has 256 values.

Hex codes describe sRGB colors. An app that uses Display P3 or a print profile can show the same code a little differently.