HEX to RGB Converter

Convert a HEX colour code to RGB and HSL.

Color Tools Free, no sign-up Runs in your browser

HEX to RGB Converter tool

Accepts 3, 4, 6 or 8 digits. The leading hash is optional.

Converted values

Channels

0
Red
0
Green
0
Blue
1
Alpha

About the HEX to RGB Converter

A HEX colour code packs three numbers into one string. Each pair of hexadecimal digits represents one channel, from 00 to FF, which is 0 to 255 in decimal. HEX to RGB Converter unpacks that string and shows the same colour as separate red, green and blue values, and as hue, saturation and lightness.

All four common HEX lengths are accepted. The three-digit shorthand expands each digit, so #f90 means #ff9900. Six digits is the standard form. Four and eight digit values carry an alpha channel for transparency, which is reported as a value between 0 and 1 in the rgba output. The leading hash is optional.

Converting to RGB is useful when a value needs an alpha channel or when you are working with code that takes separate channels. Converting to HSL is useful when you want to adjust the colour rather than simply restate it, because lightness and saturation are far easier to tune by hand than three independent channels.

How to use the HEX to RGB Converter

  1. Enter a HEX codeType or paste a value with or without the leading hash.
  2. Check it is validInvalid characters or lengths produce a clear message rather than a wrong answer.
  3. Read the RGB and HSL valuesBoth formats appear with a live preview of the colour.
  4. Copy the format you needEach value has its own copy button.

Features

  • Accepts three, four, six and eight digit HEX values
  • Leading hash optional
  • Outputs rgb, rgba, hsl and hsla strings
  • Live preview of the converted colour
  • Clear validation message for malformed input
  • Copy any value in one click

Who uses this tool

The hex to rgb converter is used by writers, developers, students, marketers and anyone else who needs the job done once without installing software. Common cases include:

  • Converting a brand HEX code into RGB for a gradient
  • Adding transparency to an existing solid colour
  • Moving a palette from a design file into CSS
  • Getting HSL values so a colour can be lightened predictably
  • Checking that a HEX value from a spec is well formed

Frequently asked questions

What makes a HEX code valid?

It must contain only the digits 0 to 9 and the letters A to F, and be three, four, six or eight characters long after the optional hash. Anything else, such as a typo that uses the letter G, is rejected with a message.

What do the extra two digits in an eight-digit HEX mean?

They are the alpha channel, controlling opacity from 00 for fully transparent to FF for fully opaque. The converter reports that as a decimal between 0 and 1 in the rgba output.

Is #FFF the same as #FFFFFF?

Yes. Each digit in the shorthand form is doubled, so #FFF expands to #FFFFFF and #F90 expands to #FF9900. The shorthand only works when both digits of each pair match.

Does HEX capitalisation matter?

No. Upper and lower case hexadecimal digits mean the same thing. Many teams standardise on one for tidiness, but browsers accept both.

Why would I want HSL instead of RGB?

Because it maps to how people describe colour. Raising lightness gives a tint, lowering it gives a shade, and dropping saturation mutes the colour, all without touching the hue.

Can I convert several codes at once?

This tool converts one code at a time so it can validate each properly. For a palette, convert each colour and copy the values as you go.

If the hex to rgb converter is not quite what you need, these other free tools solve closely related problems.

RGB to HEX Converter

Enter R, G and B values and get the matching HEX and HSL colour.

Color Tools Use tool

Color Picker

Choose any colour and copy it in HEX, RGB or HSL, with tints and shades.

Color Tools Use tool

Image Compressor

Compress and resize JPEG, PNG and WebP images privately in your browser.

Image Tools Use tool

JSON Formatter

Pretty-print and validate JSON, with the exact line and column of any error.

Developer Tools Use tool

Base64 Encoder

Encode any text, including emoji and accents, to a Base64 string.

Encoding & Conversion Use tool