Skip to content
Processing locally — files never leave your device

Color Converter

Pick a color or paste a value and convert instantly between HEX, RGB, and HSL, with a live swatch and a copy button for each format. Useful for matching brand colors across CSS, design tools, and SVG, or for turning a HEX code pulled from a screenshot into the RGB or HSL values your stylesheet needs.

R
G
B
H°
S%
L%
HEX
#6366f1
RGB
rgb(99, 102, 241)
HSL
hsl(239, 84%, 67%)
Bloggers — embed this widget for free

Add this tool to your own site with one line of HTML. Free forever — just keep the small credit link.

How to use Color Converter

  1. Pick a color from the visual picker, or type any value — HEX (#3b82f6), rgb(59, 130, 246), or hsl(217, 91%, 60%).
  2. The moment you change one field, every other format recalculates and updates in place.
  3. Read the HEX, RGB, and HSL values side-by-side to compare representations of the same color.
  4. Click any value to copy it straight to your clipboard, ready to paste into CSS or a design tool.
  5. Nudge the HSL lightness or saturation to build lighter and darker variants of the same hue.

Understanding HEX, RGB, HSL, and HSV

Every color you see on screen is the same physical thing — a mix of red, green, and blue light. The four notations below are just different ways of writing that mix down. Knowing how they relate makes it far easier to read a value, tweak it, and move it between CSS, design tools, and code.

HEX: RGB in base-16

A HEX code such as #3b82f6 packs three channels into six hexadecimal digits — two for red, two for green, two for blue. Each pair ranges from 00 (0) to ff (255). It is the most compact notation and the default in most design handoffs, but the digits are hard to reason about by eye because base-16 is not intuitive.

RGB: the raw channels

RGB writes the same three channels as plain decimal numbers from 0 to 255:

#3b82f6  →  rgb(59, 130, 246)

This is the same color, just easier to read. RGB is handy when you are computing colors in code, since you can manipulate each channel as an ordinary integer before formatting it back to HEX.

HSL: hue, saturation, lightness

HSL re-maps the RGB cube onto a cylinder that matches how people think about color. Hue is an angle from 0 to 360 degrees (0 = red, 120 = green, 240 = blue), saturation is how vivid the color is, and lightness runs from black to white:

#3b82f6  →  hsl(217, 91%, 60%)

To build a darker shade of the same color, drop the lightness; to mute it, drop the saturation — all without touching the hue. That predictability is why HSL is the go-to format for generating color scales and hover states.

HSV vs HSL

HSV (also called HSB) shares the hue and saturation axes but replaces lightness with value. In HSL, 100% lightness is always white; in HSV, 100% value is the brightest version of the hue itself. Color pickers in tools like Photoshop and Figma are usually HSV, which is why dragging to the top-right corner gives you a fully saturated color rather than white.

A worked example: turning one brand color into a usable palette

Say a design hands you a single brand blue, #3b82f6, and you need a hover state, a disabled state, and a tinted background from it. Convert to HSL first, because that is the format where the math is intuitive:

#3b82f6           →  hsl(217, 91%, 60%)   base
hover  (darker)   →  hsl(217, 91%, 52%)   →  #156bf4
disabled (muted)  →  hsl(217, 30%, 60%)   →  #7a92b8
tint   (lighter)  →  hsl(217, 91%, 95%)   →  #e7f0fe

Every variant keeps the hue locked at 217, so the family stays recognisably the same blue. The hover state only drops lightness by 8 points; the disabled state pulls saturation down to grey it out without changing how light it is; the tint pushes lightness near the top for a subtle background. Once the HSL values look right, copy each one back as HEX for your stylesheet — exactly the round-trip this converter does in place. Trying to do the same edits directly in HEX would mean recomputing all three channels by hand for every step.

Rounding and precision

HEX and RGB are both 8-bit integers per channel, so they convert back and forth perfectly. HSL uses integer degrees and percentages, so a round-trip through HSL can shift a channel by one unit. When exact reproduction matters, keep HEX or RGB as the canonical value and treat HSL as an editing convenience.

Related dev tools

Frequently asked questions

What format should I use for CSS?
Modern CSS accepts HEX, rgb(), hsl(), and the newer oklch() format. HEX is the shortest to write; HSL is the most human-friendly when you need to tweak lightness or saturation by hand because the three numbers map to intuitive concepts (hue angle, saturation, lightness).
How does HEX map to RGB?
A 6-digit HEX code is just RGB written in base-16. #3b82f6 splits into 3b, 82, and f6 — the red, green, and blue channels. Convert each pair from hexadecimal to decimal (3b = 59, 82 = 130, f6 = 246) and you get rgb(59, 130, 246). The converter does this both ways instantly.
Why does my HEX shorthand look different?
Three-digit shorthand like #abc expands by doubling each digit to #aabbcc, so #abc and #aabbcc are identical. But #abc and #abcdef are not — shorthand only works when each channel uses a repeated digit. When in doubt, use the full 6-digit form.
How is HSL calculated from RGB?
HSL is derived from the max and min of the normalized R, G, and B channels. Lightness is the average of the max and min; saturation depends on how far lightness sits from 0 or 1; hue is the angle (0–360°) computed from which channel is largest. It is a cylindrical re-mapping of the same RGB cube, not a different color space.
What is the difference between HSL and HSV?
Both use a hue angle, but HSL's third axis is lightness (0% = black, 100% = white, 50% = the pure hue) while HSV's is value/brightness (0% = black, 100% = the brightest version of the hue). HSL is symmetric around the mid-point; HSV maxes out at full color. CSS uses HSL.
Does this support alpha (transparency)?
This version handles solid HEX, RGB, and HSL only. If you need transparency, take the values shown here and wrap them in CSS rgba() or hsla() — for example rgba(59, 130, 246, 0.5) — adding your own alpha between 0 and 1.
Are these conversions lossless?
RGB and HEX round-trip exactly because both are 8-bit-per-channel integers. HEX↔HSL can lose a unit during rounding, since HSL percentages and degrees are integers in CSS — converting to HSL and back may shift a channel by 1. For exact values, keep HEX or RGB as your source of truth.

More tools you might find useful in the same flow.

Built by Muhammad Tahir · About