Skip to main content
Tools Star Hub

Developer Tools

How to Convert a Hex Color to RGB

By Tools Star Hub Editorial Team · Published · Updated

A hex color stores red, green, and blue as base-16 pairs. #336699 is red 51, green 102, and blue 153, which is rgb(51, 102, 153). The same color is hsl(210, 50%, 40%), and the short form #369 is the same color. #fff is #ffffff, which is rgb(255, 255, 255). The converter accepts 3-digit, 6-digit, and 8-digit hex, with or without a #.

Design tools, CSS, and image editors do not all show the same notation. Converting the hex lets you paste the form the next tool expects. The page also shows HSL, which is useful when you want to talk about hue and lightness. It does not accept color names such as red.

How do the hex pairs become channel numbers?

A 6-digit hex is three pairs: rr, gg, and bb. Each pair is a base-16 number from 00 to ff, which is 0 to 255 in decimal. 33 is 51, 66 is 102, and 99 is 153. That is why #336699 is rgb(51, 102, 153).

A 3-digit hex repeats each digit. #369 is #336699. #fff is #ffffff. An 8-digit hex adds an alpha pair. The page reports whether alpha is present and shows both rgb() and rgba() forms.

How to Convert a Hex Color to RGB — Tools Star Hub

What else does the page return?

#336699 is also hsl(210, 50%, 40%). Hue, saturation, and lightness are derived from the same red, green, and blue channels. They are a different way to write the color, not a different color.

The word red is rejected. The message says to use 3-digit, 6-digit, or 8-digit hex, with or without #. Named CSS colors and rgb() input are outside this converter. Paste the hex.

How should you use the result?

Copy rgb(51, 102, 153) into CSS when a field wants the function form. Copy #336699 when it wants hex. The short form #369 is safe in CSS for this color because it expands to the same channels.

Contrast is a separate question. Two hex values can be converted and still fail a contrast check. Use the contrast checker when the color will sit on text. This converter does not score readability.

Eight-digit hex adds alpha as the last pair. ff at the end is fully opaque, and 00 is fully transparent. The page shows rgba() and hsla() when that pair is present. A 6-digit color such as #336699 has no alpha pair, so alpha stays 1.

Channel order is red, then green, then blue. #336699 is red 51, green 102, and blue 153. Reading the pairs from the left avoids swapping a CSS value. The short form repeats digits. It does not mean the missing digits are zero.

Copy the form the next field expects. A CSS color property accepts both #336699 and rgb(51, 102, 153). A design tool that wants only hex will not accept the rgb function. The converter shows both so you can pick the one that fits.

Lowercase and uppercase hex digits are the same value. #ff0000 and #FF0000 are both red 255, green 0, and blue 0. The page normalizes the hex it shows. Paste either case.

How to convert a hex color to RGB

  1. Paste the hex. Include # or leave it off. Use 3, 6, or 8 hex digits. Other lengths are rejected.
  2. Read the red, green, and blue numbers. Each channel is an integer from 0 to 255. #336699 is 51, 102, and 153.
  3. Copy the CSS form you need. The page shows hex, short hex when one exists, rgb, rgba, hsl, and hsla.
  4. Check contrast separately if the color is for text. Conversion does not tell you whether the color is readable on a background.

Example

#336699

The page returns rgb(51, 102, 153), hsl(210, 50%, 40%), and the short hex #369. Alpha is 1, so the color is fully opaque.

#fff

#fff expands to #ffffff and rgb(255, 255, 255). The three f digits are repeated, not interpreted as a 3-digit number.

Common mistakes

Color names are not hex

red, white, and similar words are rejected. Paste #ff0000 or another hex value instead.

3 digits are repeated, not padded with zeros

#369 becomes #336699, not #369000. Each digit is doubled.

FAQ

What is #336699 in RGB?
rgb(51, 102, 153). The pairs 33, 66, and 99 are 51, 102, and 153 in decimal. The HSL form is hsl(210, 50%, 40%).
Is #369 the same color?
Yes. A 3-digit hex repeats each digit, so #369 is #336699.
What does #fff become?
#ffffff and rgb(255, 255, 255).
Can I type the word red?
No. The page asks for 3-digit, 6-digit, or 8-digit hex, with or without #.
Does the conversion leave the browser?
No. The hex is parsed in this tab.

To turn hex into RGB and HSL, use the Hex to RGB converter. It accepts 3-digit, 6-digit, and 8-digit hex.

To pick a color another way, read How to pick a color.

For text on a background, see How to check color contrast.