Colour converter

Convert colours between HEX, RGB and HSL, with a preview and a description, in your browser.

Everything happens on your device. What you type never leaves it.

No colour yet. The preview and a description appear here.

  • RGB
  • HSL

This tool needs JavaScript to run

About this tool

This tool converts a colour between the three notations used in CSS: HEX, RGB and HSL. Type or paste a colour in any of them and the other two appear as you type, together with a preview swatch and a description in words, so you can see and read what the colour is. The result is also given as a lower case HEX value, which is what the Copy button copies.

It understands HEX with 3, 4, 6 or 8 digits (with or without the # sign), rgb() and rgba(), and hsl() and hsla(), written with commas or with spaces and a slash before the alpha. A value that does not fit, such as a red of 300 or a HEX colour with five digits, is not quietly changed: you are told what is wrong and where.

Everything happens on your device. What you type is never sent to a server, and after your first visit the tool also works with no connection. Colour names such as "red" are not supported; use a number-based notation.

Examples

HEX to RGB and HSL

Input

#336699

Output

#336699
rgb(51, 102, 153)
hsl(210, 50%, 40%)

A colour with transparency

Input

rgba(255, 0, 0, 0.5)

Output

#ff000080
rgba(255, 0, 0, 0.5)
hsla(0, 100%, 50%, 0.5)

Short HEX

Input

#fc0

Output

#ffcc00
rgb(255, 204, 0)
hsl(48, 100%, 50%)

Common questions

Is the colour I type sent anywhere?

No. The conversion is done by code running in your browser. Nothing is sent to ajx.io or to anyone else, and the tool keeps working if you go offline.

Which formats can I type?

HEX with 3, 4, 6 or 8 digits, such as #369, #3698, #336699 or #33669980; rgb() and rgba(), such as rgb(51, 102, 153) or rgb(51 102 153 / 50%); and hsl() and hsla(), such as hsl(210, 50%, 40%). Upper and lower case both work.

How is transparency handled?

A fourth number in rgb() and hsl(), or a fourth and eighth HEX digit pair, is the alpha, from 0 (fully transparent) to 1 (fully opaque). The HEX result gets two extra digits when the colour is not fully opaque, and none when it is.

Why can a converted colour differ by one in a channel?

HSL shows whole degrees and whole percentages, so turning an HSL value back into RGB can differ from the original by a step. HEX and RGB hold the same numbers, so they convert in both directions without any change.

Why is there a description as well as a swatch?

A colour shown only as a patch of colour cannot be read by everyone, so the tool also says it in words, for example "Medium blue", with the hue, saturation and lightness and how opaque it is.