ToolDash
RGB to HEX Converter

RGB to HEX Converter

Type an RGB color and get its HEX code straight away, along with HSL and 8-digit hex when there is transparency. This RGB to HEX converter also has sliders, a color picker and an eyedropper where your browser supports one.

  • Free, no sign-up
  • Runs in your browser — nothing is uploaded
  • Instant results, no waiting on a server

Type an RGB color such as rgb(255, 87, 51) to get its HEX code, plus HSL and 8-digit hex. Use the sliders, color picker or eyedropper to choose one instead.

Color
#ff5733
Red255
Green87
Blue51
Alpha100%

HEX

#ff5733

HEX (uppercase)

#FF5733

RGB

rgb(255, 87, 51)

HSL

hsl(10.6, 100%, 60%)

RGB (CSS Color 4)

rgb(255 87 51)

HSL (CSS Color 4)

hsl(10.6 100% 60%)

RGB values

255, 87, 51

HSL values

10.6, 100%, 60%
WCAG contrast

White text on this color

3.15 : 1

AA failLarge pass

Black text on this color

6.66 : 1

AA passLarge pass

AA needs 4.5:1 for body text and 3:1 for large text (24px, or 18.66px bold). Alpha is ignored here.

How to convert RGB to HEX

  1. 1To convert RGB to HEX, type your color into the RGB, HEX or HSL box as rgb(255, 87, 51), or as three numbers with commas. It is converted as you type.
  2. 2Prefer sliders? Drag the Red, Green and Blue sliders, or click the swatch to open your color picker. On Chrome and Edge, the Eyedropper button samples any color on your screen.
  3. 3Copy the HEX result, lowercase or uppercase, with its copy button. The same card list also gives you HSL and the CSS Color 4 forms.
  4. 4If your color has transparency, use rgba() or move the Alpha slider and copy the 8-digit hex, which carries the opacity in its last two digits.

How RGB turns into HEX

RGB describes a color with three numbers from 0 to 255 for red, green and blue. HEX writes the very same three numbers in base 16, two digits per channel, with a hash in front. To convert RGB to hex you change each number to base 16 and join the results: rgb(255, 87, 51) gives ff for red, 57 for green and 33 for blue, so the hex code is #ff5733. Because both are exact integer notations, the conversion is lossless and works in both directions.

Each channel must be padded to two digits, which is the step people forget by hand. A value of 5 becomes 05, not 5, so rgb(0, 5, 255) is #0005ff. Values above 255 or below 0 are invalid. This converter checks for that and tells you what it could not read instead of guessing. It accepts commas or spaces, so rgb(255 87 51) and rgb(255, 87, 51) give the same answer.

RGBA adds a fourth value, the alpha, from 0 to 1 or as a percentage. To convert rgba to hex, the alpha is multiplied by 255 and written as two more hex digits at the end, so rgba(255, 87, 51, 0.5) becomes #ff573380. Eight-digit hex is supported by every current browser. The tool also gives the color in HSL, which describes the same color as a hue angle, a saturation and a lightness, a more natural way to make lighter or darker versions.

A WCAG contrast panel below the results shows whether white or black text is readable on your color. Everything runs in your browser, so nothing you type is sent anywhere, and there is no limit on conversions.

When people convert RGB values to hex

CSS and design handoff

Designers often give colors as RGB values; developers usually want a hex code to paste into a stylesheet or a token file.

Using image editor colors

Photoshop, Figma and screenshots report RGB numbers. Turn them into an RGB color to hex value you can use on the web.

Adding opacity

Convert an rgba color to an eight-digit hex for tools that don't accept the rgba() function.

Matching brand colors

Check that a brand RGB value and its hex code describe exactly the same color across print, web and app.

Frequently asked questions

How do I convert RGB to HEX?

+

Type the RGB value into the converter and copy the HEX result. By hand, convert each of the three numbers to base 16 with two digits and put them together after a hash sign.

Where can I get an RGB to hex code online?

+

Right here. Enter the values and the RGB to hex code appears at once, with a copy button. It works as an RGB to hex online tool without any upload or sign-up.

What is rgb(255, 255, 255) in hex?

+

It is #ffffff, white. Every channel is at its maximum, 255, which is ff in base 16. rgb(0, 0, 0) is #000000, black.

Can I convert RGBA to HEX?

+

Yes. Paste the rgba() value and copy the 8-digit hex. The alpha becomes the last two digits, so an alpha of 0.5 is 80.

Is the conversion exact?

+

Yes. RGB and HEX are both whole numbers from 0 to 255, so no rounding is involved when you convert RGB to hex and back.

Can I also get HSL from an RGB color?

+

Yes. The same result list shows RGB to HSL, rounded to one decimal place, plus the modern space-separated CSS syntax.

Is my color sent to a server?

+

No. The conversion runs in your browser and nothing leaves your device.