HEX, RGB and HSL Color Converter – Free

Type a hex code or an rgb() value and this color converter prints the same color as uppercase HEX, RGB and HSL, ready to paste into a stylesheet.

How to use the Color converter tool

  1. Enter a color in the Color field, for example #0e6970, #f80 or rgb(255, 136, 0).
  2. Select Convert. To try it without typing, select Example.
  3. Read the HEX, RGB and HSL lines in the Result box.
  4. Select Copy to copy all three lines, or Clear to empty the field.

How HEX, RGB and HSL describe the same color

A hex code is the RGB triple written in base 16. Each pair of digits is one channel from 00 to ff, so #0e6970 means red 14, green 105 and blue 112. The three-digit short form doubles each digit: #f80 is the same color as #ff8800.

HSL describes that color by hue, saturation and lightness. Hue is an angle on the color wheel with red at 0, green at 120 and blue at 240 degrees. Lightness is the midpoint between the largest and smallest channel, and saturation measures how far apart those two channels are relative to that lightness. Designers like HSL because a tint or shade is a change to one number.

Worked example: converting #0e6970 by hand

Scale the channels to the range 0 to 1: 14, 105 and 112 become about 0.055, 0.412 and 0.439. The largest is blue and the smallest is red. Lightness is (0.439 + 0.055) / 2 = 0.247, or 25%. The spread between them is 0.384, and saturation is 0.384 / (1 - |2 x 0.247 - 1|) = 0.778, or 78%.

Because blue is the largest channel, hue is 60 x ((red - green) / spread + 4), which comes to 184 degrees. That places the color between green and blue: a dark teal.

Color: #0e6970

HEX: #0E6970
RGB: rgb(14, 105, 112)
HSL: hsl(184, 78%, 25%)

Input formats the color converter accepts

Input is parsed strictly, and conversion goes one way, from HEX or RGB to all three notations. Not accepted: hex without the #, 4- or 8-digit hex with alpha, rgba(), percentages or decimals inside rgb(), hsl() as input, and CSS color names such as red.

A value that matches none of the forms below stops with the message Enter a 3- or 6-digit hex color or rgb(r, g, b).

  • Six-digit hex with a leading #, in upper or lower case: #1E90FF or #1e90ff.
  • Three-digit hex with a leading #: #fff or #f80.
  • rgb() with three whole numbers from 0 to 255, separated by commas or by spaces: rgb(30, 144, 255) or rgb(30 144 255).
  • Spaces before or after the value are ignored.

Rounding and round trips

Hue, saturation and lightness are rounded to whole numbers. That keeps the output short, but several RGB colors can share one rounded HSL value, so converting the HSL line back to RGB elsewhere may land a step or two away from the original. Treat the HEX and RGB lines as exact and the HSL line as the nearest whole-number match.

Grays have no hue, so the tool reports hue 0 and saturation 0% for them: #808080 becomes hsl(0, 0%, 50%). All three output lines are valid CSS color values.

Frequently asked questions

How do I convert HEX to RGB?

Split the six digits into three pairs and read each pair as a base 16 number. For #1e90ff, 1e is 30, 90 is 144 and ff is 255, giving rgb(30, 144, 255). Paste the code into the Color field and the tool does this for you.

Can I enter an HSL color and get HEX back?

No. The Color field takes hex codes and rgb() values only, and HSL is an output format here. Entering hsl(184, 78%, 25%) returns the format error instead of a conversion.

Does it support alpha or 8-digit hex colors?

No. Values such as #0e697080 or rgba(14, 105, 112, 0.5) are rejected. Drop the alpha part, convert the opaque color, and add the transparency back in your CSS afterward.

Why is the HEX output uppercase?

The tool prints hex digits in capitals and always expands the short form to six digits, so #f80 comes back as #FF8800. CSS treats hex colors as case-insensitive, so you can lowercase the value if your code style prefers it.

Related tools