Color Converter for HEX, RGB and HSL with Live Swatch
Convert colors between HEX, RGB and HSL with a live swatch
#3b82f6rgb(59, 130, 246)hsl(217, 91%, 60%)What is a color converter?
The same color can be written as a hex triplet, an rgb() function, or an hsl() function, and different parts of a codebase — a design tool's export, a CSS-in-JS theme file, an old stylesheet — tend to favor different ones. This tool parses whichever format you paste and shows the equivalent hex, RGB, and HSL values side by side, along with a live swatch so you can confirm it's the color you expect.
HSL in particular is useful beyond just display: because it separates hue from saturation and lightness, it's the easiest format to reason about when you want a lighter or darker variant of an existing brand color without guessing at RGB channel math.
When to use it
Use it when a designer hands you a hex value and your codebase's theme uses HSL custom properties (common in Tailwind/shadcn setups), or vice versa. It's also useful for sanity-checking a color pulled from a screenshot or a browser's color picker, or for quickly generating the HSL breakdown of a color so you can tweak lightness for a hover or disabled state.
The input accepts 6-digit and 3-digit hex (with or without the #), rgb()/rgba(), and hsl()/hsla() — paste any of them and the other two are derived automatically.
Example
Paste #3b82f6 and the tool resolves it to rgb(59, 130, 246) and hsl(217, 91%, 60%) — a mid-tone blue. Try lowering the lightness in the HSL value (e.g. to 40%) and converting that back to see a darker shade of the same hue, which is exactly the workflow for deriving a :hover state from a base color.
How to use the Color Converter for HEX, RGB and HSL with Live Swatch tool
- 1
Paste a color
Enter a hex code, rgb()/rgba(), or hsl()/hsla() value.
- 2
Click Convert
The tool detects the format and computes the other two representations.
- 3
Read the swatch and values
A live color preview sits alongside the HEX, RGB, and HSL strings.
- 4
Copy or share
Copy any individual value, or copy a permalink that restores your input for anyone who opens it.
Frequently asked questions
Is my input sent to a server?
No — parsing and conversion happen entirely in your browser's JavaScript.
Why does it say "Invalid color format"?
The parser expects a complete hex (3 or 6 digits, with or without #), or a well-formed rgb()/rgba()/hsl()/hsla() function call with numeric components. Named colors like "cornflowerblue" and newer syntaxes like oklch() or space-separated rgb(59 130 246) aren't recognized — convert those to a supported format first.
Does alpha/opacity carry through?
The tool reads the alpha channel from rgba()/hsla() input if present but the output focuses on the opaque hex/RGB/HSL values — for a color with transparency, keep the alpha component from your original value.
How does hex-to-HSL rounding work?
Hue, saturation, and lightness are rounded to the nearest whole number for readability, which means converting HSL back to hex and forth again can shift the very last bit of a channel — negligible visually, but worth knowing if you're diffing exact values.
Related on TechLogHub
Related Colors Tools
Get the next tool before you need it
One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.

