Skip to content
en

Color Converter

Converts a color between HEX, RGB and HSL. The format is detected on its own, transparency is kept, and a hint says which text will read on this background.

Input

Result

Fill in the fields – the result will appear here.

Report a problem
This will be sent with your message:
Advertisement

HEX, RGB and HSL – one color, three ways to write it

These are not different colors

HEX, RGB and HSL describe the same point in the sRGB space, just in different words. #3b82f6, rgb(59, 130, 246) and hsl(217, 91%, 60%) are one blue. So converting between them is not "approximate": no information is lost on the way.

HEX is the same three channels

Two digits per channel, in hexadecimal: 3b is 59, 82 is 130, f6 is 246. The short form #38f just doubles each digit, so it equals #3388ff. The eight-digit form #3b82f6cc adds a fourth channel – transparency.

RGB – how much of each light

Three numbers from 0 to 255: how much red, green and blue. The format is handy for a machine and awkward for a person: to make the same color a bit lighter, you have to move all three numbers at once.

HSL – the one that is easy to think in

Hue in degrees on the color wheel (0 is red, 120 is green, 240 is blue), saturation in percent and lightness in percent. That is why themes are written in HSL: a lighter version of the same color is just higher lightness, and the other numbers stay put.

Rounding lives only in HSL

Hue, saturation and lightness are printed here as whole numbers, the way they are written in CSS. Because of that, converting back sometimes gives a neighboring HEX – off by one in a channel, which the eye cannot see. HEX and RGB always convert into each other exactly.

Common questions about color formats

Which format should I use in a project?

For theme variables – HSL: it makes a lighter and darker version of the same color easy. For values that come from a mockup or a designer – HEX, because every editor shows it. RGB is more often needed where code works out the color.

Why did the HEX change after going to HSL and back?

Because HSL is rounded to whole numbers. The difference is one or two in a channel, and it does not show on screen. If the color has to stay exactly the same bit for bit, keep the HEX and convert from it, not in a circle.

How do I write transparency?

Three ways, and they all mean the same: #3b82f6cc, rgba(59, 130, 246, 0.8), hsla(217, 91%, 60%, 0.8). In HEX, transparency is the last two digits, a number from 00 to ff; in the functions it is a number from 0 to 1.

Does the tool understand color names?

No, it does not accept red or rebeccapurple. CSS has 148 named colors, which is a table, not a format, and the page does not pretend to know it by heart. Enter a value from an eyedropper or an editor.

Why does it say which text will read on top?

It is the relative luminance of the color by WCAG 2.1: above the threshold, dark text sits better on top, below it – light text. It is a hint, not a contrast check – the contrast checker works out the exact ratio for a specific pair of colors.

Advertisement

Report a problem

This will be sent with your message: