Developer Tools calculator

Free hex / RGB / HSL color converter

Enter a hex color (or use the picker) and this color converter reads out the matching RGB and HSL — #RRGGBB, rgb(r, g, b) and hsl(h, s%, l%), the same color three ways, updated live, as you type.

InputsLive
Tool
Input
Result
Base64
Enter input above to get started.

Output is generated client-side in your browser. No data is transmitted to any server.

Results are estimates. Consult a professional.

What it does

What this color converter does

This color converter takes one color and shows it in the three formats CSS and design tools use every day: HEX (#RRGGBB), RGB (rgb(r, g, b)) and HSL (hsl(h, s%, l%)). Type a hex value — or pick a shade with the color picker — and the matching RGB and HSL strings appear instantly, ready to copy straight into your stylesheet.

All three are the same color written three ways. HEX and RGB describe how much red, green and blue light to mix. HSL describes the same point by its hue, saturation and lightness, which is far easier to tweak by hand. The converter does the arithmetic so you do not have to convert hex to RGB or RGB to HSL in your head.

One input, three answers
The tool reads a HEX color (or the picker) and reports the equivalent HEX, RGB and HSL. It does not parse pasted rgb() or hsl() text — start from a hex value and the other two follow.
The formats

HEX, RGB and HSL explained

Each format encodes the same display color, but they read very differently. Knowing what each number means tells you which one to reach for.

HEX — #RRGGBB

A hex color is a hash followed by three pairs of hexadecimal (base-16) digits: two for red, two for green, two for blue. Each pair runs from 00 (none) to ff (full, which is 255 in decimal). So #ff0000 is pure red and #000000 is black. It is compact, case-insensitive, and the format you will paste most often.

RGB — rgb(r, g, b)

RGB writes the three channels as plain decimal numbers from 0 to 255. It is "additive" — start from black and add light, so the more of each channel, the brighter the result, and all three at full gives white. rgb(255, 0, 0) is the same pure red as #ff0000; the only difference is base 10 versus base 16.

HSL — hsl(h, s%, l%)

HSL re-describes the color the way a person thinks about it. Hue is an angle from 0 to 360° around the color wheel (0° red, 120° green, 240° blue). Saturation is a percentage from 0% (grey) to 100% (vivid). Lightness is a percentage from 0% (black) through 50% (the pure hue) to 100% (white). The percent signs are part of the syntax — hsl(220, 60%, 50%), not hsl(220, 60, 50).

HEX, rgb() and hsl() notations are all defined in the CSS Color Module Level 3 specification (W3C), the standard CSS browsers implement for these formats.
How it works

How the conversion works

There are two conversions under the hood, and they are very different in character. HEX and RGB are the same numbers in different bases. HSL is a genuine reshaping of those numbers into hue, saturation and lightness.

  • HEX ↔ RGB is a base change. Each two-digit hex pair is one channel read in base 16. 33 is 3×16 + 3 = 51, 66 is 6×16 + 6 = 102, cc is 12×16 + 12 = 204. To go back, write each 0–255 channel as two hex digits. No color information changes — only the way the digits are written.
  • RGB ↔ HSL is a transform. Divide each channel by 255, find the largest and smallest of the three, and derive lightness from their midpoint, saturation from their spread, and hue from which channel leads. It is the standard formula in the CSS spec.
R, G, B → divide each by 255 → R', G', B'
max = largest of R',G',B' min = smallest
L = (max + min) / 2
S = 0 if max = min, else spread / (1 |2L 1|)
H = 60° × position on the wheel of the leading channel
Runs in your browser
Every conversion is plain arithmetic computed locally — the color you enter is never sent to a server, so the tool works the same offline and stores nothing.
Example

A worked example: #3366CC across all three formats

Example: converting the hex color #3366CC

Enter #3366CC — a mid blue — and watch it become RGB and HSL. We will work each step by hand, then confirm it against the converter.

Step 1 — HEX to RGB (read each pair in base 16)

Split into three pairs: 33, 66, CC. In decimal that is 3×16+3 = 51, 6×16+6 = 102, and 12×16+12 = 204. So the color is rgb(51, 102, 204).

Step 2 — RGB to HSL (find lightness, saturation, hue)

Scale to 0–1: 0.200, 0.400, 0.800. The max (0.800, blue) and min (0.200, red) average to 0.500, so L = 50%. The spread gives S = 60%. Blue leads, placing the hue near the blue side of the wheel at H = 220°.

Step 3 — Read off the result

The color is hsl(220, 60%, 50%). Type #3366CC into the converter and it reports exactly rgb(51, 102, 204) and hsl(220, 60%, 50%) — the same blue, three ways.

#3366CC = rgb(51, 102, 204) = hsl(220, 60%, 50%)
Now drop the lightness in that HSL to 40% for a darker blue, or the saturation to 30% for a muted one — that one-number control is what makes HSL so handy for tweaking.
Choosing a format

When to use HEX, RGB or HSL

Browsers treat all three identically, so the "best" format is whichever is easiest for the job in front of you. A rough rule: HEX and RGB for code and exact values, HSL for thinking and tweaking.

  • HEX — shortest to write and the de-facto default in design tools, brand guides and most stylesheets. Best when you just need to drop in an exact color.
  • RGB — when a value comes from an image, a pixel reading or a tool that thinks in 0–255 channels, or when you need the alpha form rgb(r g b / a).
  • HSL — when you are designing relationships between colors. To make a shade darker, lower the lightness. To mute it, lower the saturation. To build a palette, keep the hue and vary the other two. That is awkward in HEX or RGB and obvious in HSL.
A practical workflow: pick the color in HEX, convert it to HSL here, and adjust the lightness and saturation by hand to generate hover states, borders and tints that all share the same hue.
Reference

Common colors in HEX, RGB and HSL

A quick lookup for everyday colors across all three formats. Each row is the identical color written three ways — exactly what the converter outputs for that hex value.

ColorHEXRGBHSL
Black#000000rgb(0, 0, 0)hsl(0, 0%, 0%)
White#FFFFFFrgb(255, 255, 255)hsl(0, 0%, 100%)
Red#FF0000rgb(255, 0, 0)hsl(0, 100%, 50%)
Green (lime)#00FF00rgb(0, 255, 0)hsl(120, 100%, 50%)
Blue#0000FFrgb(0, 0, 255)hsl(240, 100%, 50%)
Yellow#FFFF00rgb(255, 255, 0)hsl(60, 100%, 50%)
Cyan#00FFFFrgb(0, 255, 255)hsl(180, 100%, 50%)
Magenta#FF00FFrgb(255, 0, 255)hsl(300, 100%, 50%)
Mid grey#808080rgb(128, 128, 128)hsl(0, 0%, 50%)
Orange#FFA500rgb(255, 165, 0)hsl(39, 100%, 50%)
Teal#008080rgb(0, 128, 128)hsl(180, 100%, 25%)

Values computed with the CSS Color Module Level 3 conversion; HSL channels are rounded to whole numbers, matching the converter's output.

Transparency

Alpha and opacity: RGBA, HSLA and 8-digit hex

The three formats above describe opaque colors — and so does this converter. To add transparency, CSS extends each format with an alpha channel from 0 (fully transparent) to 1 (fully opaque):

  • RGBArgba(51, 102, 204, 0.5), or the modern slash form rgb(51 102 204 / 50%), for the example blue at half opacity.
  • HSLAhsla(220, 60%, 50%, 0.5), the same half-transparent blue in HSL.
  • 8-digit hex#3366CC80 adds a fourth pair for alpha (80 ≈ 50%), supported in all modern browsers.
This converter outputs opaque colors only — the alpha channel is separate. Take the HEX or RGB it gives you and append the alpha value your design needs.
Alpha syntax for rgb(), hsl() and hex (the optional fourth value) is documented by MDN in its color value reference.
Common mistakes

Common color-format mistakes (and how to avoid them)

Most "the color isn't applying" bugs come from small syntax slips. These are the ones that catch people out.

  • Three-digit vs six-digit hex. #36c is valid shorthand for #3366cc — each digit is doubled. But #36cc (four digits) is not a color. Stick to 3, 6, or (with alpha) 4 or 8 digits.
  • Forgetting the % in HSL. Saturation and lightness must carry a percent sign: hsl(220, 60%, 50%) works, hsl(220, 60, 50) does not. Hue takes no unit.
  • Channel range mix-ups. RGB channels run 0–255, not 0–100. rgb(60%, 60%, 60%) is legal but means percentages, not raw values — don't mix the two.
  • Dropping the hash. 3366cc with no # is not a valid CSS color, even though many tools accept it. The converter is forgiving about the hash; your stylesheet may not be.
One more, often overlooked: a color that reads fine to you may fail an accessibility contrast check against its background. Whether text is readable depends on the contrast ratio, which is a separate question from the color's format — run the pair through a dedicated contrast checker before shipping.
Accuracy

How accurate is this color converter?

HEX and RGB are exact in both directions — they are the same channels in different bases, with no rounding, so the conversion is lossless. The RGB→HSL step rounds the hue, saturation and lightness to whole numbers for a clean, copy-ready result, which is standard practice and matches what browsers and design tools show.

That rounding means a full round-trip (HEX → HSL → back to HEX) can occasionally land one unit off on a channel — a difference no eye can see. For pixel-exact work, keep the HEX or RGB value as your source of truth and treat HSL as the convenient view for adjusting. For more developer utilities, see our HTML entity encoder or the URL encoder.

Conversion behavior follows the CSS Color Module Level 3 specification (W3C), the same standard CSS browsers implement for hex, rgb() and hsl().
Questions

Frequently asked questions about the free hex / RGB / HSL color converter

A color converter (hex / RGB / HSL) calculator is a free online tool that helps you convert between hex, RGB, and HSL color notations with a live preview. Three equivalent ways to specify color in CSS. Hex is compact; RGB matches the underlying display; HSL maps to perceptual hue / saturation / lightness. It runs entirely in your browser with instant results and no sign-up.
HSL is more intuitive for design. To make a color darker, drop L. To make it duller, drop S. RGB requires juggling three numbers.
oklch matches human perception more accurately than HSL. Supported in modern browsers (2023+). This calculator covers the more widely supported formats.
Not in this calculator. For transparency, add a fourth value: rgba(r, g, b, a) or hsla(h, s%, l%, a) where a is 0-1.
About

About this Color Converter (hex / RGB / HSL)

This color converter runs entirely in your browser — the color you enter is never sent anywhere. Type a hex value or pick a shade, and it shows the equivalent HEX, RGB and HSL instantly, ready to copy into your CSS. It converts an opaque color between formats; alpha/opacity is handled separately.

It is one of our free developer tools; browse the full set on the calculators index.

Want a calculator built for your business?

Customize any of our 400+ tools to match your brand, or commission a new one tailored to how your business actually calculates — pricing, payroll, quotes, anything. Deployed on your domain, math runs in your visitors' browsers.