Skip to content

Hex to RGB color converter

Type any color code or pick a color to get HEX, RGB, RGBA and HSL at once, ready to copy into CSS, plus contrast ratios for white and black text.

  • Free, no limits
  • No sign-up
Everything happens in your browser; your data is never uploaded.
  • ✓ Free
  • ✓ No sign-up
  • ✓ Nothing uploaded

Next step

What to do next

How to use it

  1. Type a color code (#FF5733, rgb(255, 87, 51) or hsl(11, 100%, 60%)), or use the color picker.
  2. Fine-tune red, green, blue and alpha with the sliders.
  3. Copy the format you need with one click.
  4. Check the contrast ratio before using the color behind text.
Try it now

Color formats explained

FormatExampleNotes
HEX#FF57336 hex digits: two each for red, green and blue (00–FF)
Short HEX#F53Each digit is doubled: #FF5533
HEX + alpha#FF573380The last two digits are opacity (80 ≈ 50%)
RGBrgb(255, 87, 51)Red, green, blue from 0 to 255
RGBArgba(255, 87, 51, 0.5)Adds opacity from 0 to 1
HSLhsl(11, 100%, 60%)Hue (0–360°), saturation and lightness

The tool accepts all of these, plus three plain numbers like 255, 87, 51. Paste whatever your design tool or stylesheet gives you and every other format updates instantly.

How HEX to RGB conversion works

A HEX color is just three base-16 numbers written side by side. Split #FF5733 into pairs and convert each from hexadecimal:

  • FF = 15 × 16 + 15 = 255 (red)
  • 57 = 5 × 16 + 7 = 87 (green)
  • 33 = 3 × 16 + 3 = 51 (blue)

So #FF5733 is rgb(255, 87, 51). Going the other way, divide each value by 16: the whole number is the first digit and the remainder is the second. HSL is calculated from the same RGB values by finding the hue angle on the color wheel, how saturated the color is and how light it is.

When to use HSL

HSL is the easiest format to adjust by hand. To make a lighter or darker shade of your brand color, keep the hue and saturation and change only the lightness: hsl(11, 100%, 60%) → hsl(11, 100%, 45%). To build a palette of related colors, keep saturation and lightness and change the hue.

HEX is the most compact and is what most design tools export. RGB(A) is handy when you need transparency in older code. All modern browsers support every format here, so pick the one your team finds easiest to read.

Contrast and accessibility (WCAG)

Below the formats, the tool shows the contrast ratio of your color with white text and with black text, and the preview uses whichever reads better. The Web Content Accessibility Guidelines (WCAG 2) recommend:

  • at least 4.5:1 for normal body text (level AA),
  • at least 3:1 for large text (about 24px, or 19px bold) and for icons and UI controls,
  • 7:1 for the stricter AAA level.

A bright orange like #FF5733 reaches only about 3.1:1 with white text, which is fine for a large heading or a button icon but too low for small text. Darken it slightly, or use black text on it instead.

Quick reference: common colors

ColorHEXRGBHSL
White#FFFFFF255, 255, 2550°, 0%, 100%
Black#0000000, 0, 00°, 0%, 0%
Red#FF0000255, 0, 00°, 100%, 50%
Green (CSS lime)#00FF000, 255, 0120°, 100%, 50%
Blue#0000FF0, 0, 255240°, 100%, 50%
Gray (CSS gray)#808080128, 128, 1280°, 0%, 50%
Orange (CSS orange)#FFA500255, 165, 039°, 100%, 50%

Grays always have equal red, green and blue values, and 0% saturation in HSL. Note that the CSS keyword green is #008000, a darker shade than pure #00FF00, which CSS calls lime.

Frequently asked questions

How do I convert HEX to RGB?

Type or paste the HEX code. The RGB, RGBA and HSL versions appear instantly, each with a copy button.

Does it support transparency?

Yes. Use the alpha slider or enter an 8-digit HEX or rgba() value. The tool then also shows the HEX code with alpha.

What contrast ratio do I need for text?

WCAG AA asks for at least 4.5:1 for normal text and 3:1 for large text. The tool shows the ratio for white and black text.

Can I use a three-digit HEX code?

Yes. #F53 is read as #FF5533, and four-digit codes with alpha work too.

Is anything uploaded?

No. All conversions happen in your browser.

Sources

Last updated: November 12, 2026

Recommended

Similar tools

If Color code converter (HEX, RGB, HSL) helped, you may need these too.

See all in category →

People also use