Color Converter

Convert colors between HEX, RGB, and HSL with a live preview — edit any format and the others update instantly. Alpha transparency is preserved across all three, and everything runs in your browser so nothing is uploaded.

#3B82F6
Pick a color, or type a value →
Lightness shades — click to copy

Accepts #rgb, #rrggbb, and 8-digit #rrggbbaa hex, plus rgb()/rgba() and hsl()/hsla(). Invalid input turns the field red until it parses.

Quick answer

HEX, RGB, and HSL are three ways of writing the same color. HEX packs the red, green, and blue channels into base-16 pairs (#RRGGBB); RGB writes those channels as 0–255 numbers; HSL describes the color by hue, saturation, and lightness. Edit any field above and the other two update live — all in your browser, nothing uploaded.

How the conversions work

All three formats describe a point in the same color space, so conversion is just arithmetic:

Because HEX and RGB are limited to 256 steps per channel while HSL is continuous, an HSL → RGB → HSL round trip can round to the nearest representable color. The visible result is identical; only the final digit may move by one.

Which format to use, and when

Worked example

Take the blue #3B82F6. Converting it across formats gives:

HEX  #3B82F6
RGB  rgb(59, 130, 246)
HSL  hsl(217, 91%, 60%)

To make a hover state 15% darker, drop the HSL lightness from 60% to 45% — hsl(217, 91%, 45%) — which is far more intuitive than guessing new RGB numbers. Paste any of these into the fields above to see the others and the live swatch update.

Accessibility note

Color choice is also an accessibility decision. Text needs sufficient contrast against its background — WCAG AA asks for a contrast ratio of at least 4.5:1 for normal text. HSL makes this easier to tune: keep the hue, and adjust lightness until the contrast passes. The swatch above automatically flips its label between black and white based on the color's luminance, which is the same relative-luminance calculation contrast checkers use.

Frequently Asked Questions

How do I convert HEX to RGB?

Split the six-digit hex into three pairs and read each as a base-16 number: #3B82F6 becomes R=0x3B=59, G=0x82=130, B=0xF6=246, i.e. rgb(59, 130, 246). This tool does it instantly — paste the hex and the RGB value updates as you type.

What is the difference between RGB and HSL?

RGB describes a color by how much red, green, and blue light it mixes (0–255 each). HSL describes the same color by Hue (0–360° on the color wheel), Saturation (0–100%), and Lightness (0–100%). HSL is easier for humans to reason about — to make a color lighter you just raise the lightness, and to shift it toward another color you change the hue.

Do HEX, RGB, and HSL support transparency?

Yes. HEX supports an alpha channel as an 8-digit value (#RRGGBBAA), and CSS has rgba() and hsla() (plus modern rgb()/hsl() with a slash alpha). This converter preserves alpha across all three formats when you include it.

Is my color data sent to a server?

No. All conversion runs entirely in your browser with JavaScript. Nothing you type is uploaded, and the tool works offline once the page has loaded.

Why does my HSL value look slightly different after a round trip?

HEX and RGB store 256 discrete steps per channel, while HSL is continuous, so converting HSL → RGB → HSL can round to the nearest representable color. The visible color is effectively identical; only the last digit of the HSL numbers may shift by one.