Color HEX Converter

Convert between HEX, RGB and HSL.

Convert a color between HEX, RGB and HSL by typing in any one of the three fields; the other two update at once. Each format has a copy button and a color picker and live swatch show the result. It is for developers and designers who receive colors in one format and need another.

What are HEX, RGB and HSL?

HEX, RGB and HSL are three ways to write the same sRGB color in CSS. HEX is a hash followed by two hexadecimal digits each for red, green and blue, such as #6366f1; a fourth pair adds alpha. RGB writes the same channels as decimals from 0 to 255, such as rgb(99, 102, 241). HSL describes a color by hue in degrees from 0 to 360, saturation as a percentage and lightness as a percentage, which is easier to reason about when you want a lighter or less saturated variant. Converting between them is mathematical, though HSL values are usually rounded to whole numbers, so converting back can differ by a small amount.

How to use Color HEX Converter

  1. Enter a color Type in the HEX, RGB or HSL field, or choose a color with the picker.
  2. Watch the other formats The remaining two fields and the swatch update as soon as the input parses.
  3. Fix errors If a red message appears, correct the value. The other fields keep the last valid color until then.
  4. Copy Use the copy button next to the format you need.

Frequently asked questions

Which input formats are accepted?

HEX with 3, 4, 6 or 8 digits (hash optional), rgb() and rgba(), and hsl() and hsla(). Values may be separated by commas, spaces or a slash. Named colors like red are not supported.

Why does my HSL differ slightly when converted back?

HSL values are rounded to whole degrees and percents, which loses a little precision. Converting that rounded HSL back can land one or two steps away in a channel.

How is alpha handled?

An 8-digit HEX or a fourth number in rgba() or hsla() is treated as alpha. The outputs use rgba() and hsla() when alpha is below 1, and the HEX output gets an alpha pair.

Can I type in the HSL field without percent signs?

Yes. The parser reads the numbers in order as hue, saturation and lightness, so percent signs are optional. Output is always written with percent signs.

Does it handle CSS color functions like oklch?

No. Only HEX, RGB and HSL are supported.