devtools

Color Converter

Convert colors between HEX, RGB and HSL in your browser with a live swatch. Handles alpha, #RGB shorthand and rgb()/hsl() syntax — private and free.

Runs entirely in your browser — your data never leaves your device.

How to use Color Converter

What it does & when you need it

You have a colour in one notation and need it in another: a designer handed you #3b82f6, but your chart library wants rgb(), or you want to build a hover state by nudging lightness and HSL is the only sane way to do that. This tool takes a HEX, rgb()/rgba(), or hsl()/hsla() value and shows you all three at once, with a live swatch so you can confirm you got the colour you meant. It runs entirely in your browser — nothing about the colours you paste is sent anywhere, and it keeps working with the network disconnected.

It is built for the everyday "hex to rgb" lookup, but it also handles the fiddlier cases: alpha channels, #RGB shorthand, percentage channels, and the modern space-separated syntax (rgb(59 130 246 / 0.5)).

How to use

  1. Type or paste a colour into the color buffer, press Sample to load #3b82f6, or use the Pick swatch in the toolbar to choose one visually.
  2. The hex · rgb · hsl buffer updates as you type, listing all three forms on their own line, and the status bar shows a preview swatch plus the R/G/B channels (and alpha, when the colour is translucent).
  3. Press Copy on the output to grab all three, or hit Copy HEX (Ctrl/Cmd + Enter) to put just the hex on your clipboard. If the value can't be parsed, the output panel explains why instead of guessing.

Things worth knowing

Shorthand and alpha are just digit counts. A three-digit #RGB value is expanded by doubling each nibble, so #f0a is exactly #ff00aa — handy, but it means you can only express 4,096 colours in shorthand. The four- and eight-digit forms (#RGBA and #RRGGBBAA) add an alpha channel as a final byte, where 80 is roughly 50% opacity. This tool prints the eight-digit form only when alpha is below 1, so opaque colours stay in the short, familiar #rrggbb shape.

HSL is the notation you can edit by hand. RGB mixes three light channels, so "a slightly darker blue" means changing all three numbers in concert. HSL splits a colour into hue (0–360 degrees around the wheel), saturation, and lightness, so a tint or shade is a single nudge of the lightness percentage while hue and saturation stay put. That is why design systems and CSS custom properties so often store colours as HSL. If you're building a set of related colours, the gradient generator works from the same values.

Round-trips can drift by one. Every representation here is derived from one canonical integer RGB triple. Because RGB↔HSL conversion runs through floating point and then rounds back to whole numbers, feeding an HSL value in and reading the RGB back out can land a unit away from where you started — hsl(217, 91%, 60%) comes back as #3c83f6, not the #3b82f6 it originally described. That is expected rounding, not a bug; keep one notation as your source of truth rather than bouncing a value back and forth.

Everything here lives in the sRGB gamut. HEX and rgb() can only address colours inside sRGB (IEC 61966-2-1), the lowest-common-denominator space of the web. CSS Color Module Level 4 adds wider spaces such as oklch(), which reaches colours sRGB simply cannot show on capable displays and — unlike HSL — keeps perceived lightness constant as hue changes, so a palette doesn't look patchy. If you're picking UI colours, run the results through the contrast checker to confirm they clear WCAG ratios, and if you're converting other CSS units the px to rem converter is next door.

Examples

HEX to RGB and HSL

#3b82f6

A six-digit hex expands to rgb(59, 130, 246) and hsl(217, 91%, 60%).

Translucent rgba to hex

rgba(255, 99, 71, 0.5)

Alpha below 1 produces an 8-digit #RRGGBBAA hex.

HSL to hex

hsl(217, 91%, 60%)

Shows the one-unit rounding drift when converting HSL back to RGB.

Frequently asked questions

How do I convert a HEX color to RGB?

Paste the hex value (e.g. #3b82f6) into the input and the RGB form appears instantly as rgb(59, 130, 246). Each pair of hex digits is one 0–255 channel, so ff is 255 and 00 is 0. Everything is computed locally in your browser.

What does the alpha in an 8-digit hex like #RRGGBBAA mean?

The last two digits are an alpha (opacity) byte from 00 (fully transparent) to ff (fully opaque). For example #ff000080 is red at roughly 50% opacity, which this tool shows as rgba(255, 0, 0, 0.502). A 4-digit #RGBA works the same way with doubled nibbles.

Why does converting HSL back to RGB give a slightly different value?

Conversions run through floating-point math and then round to whole numbers, so an HSL value can land a unit away from the RGB it originally described. Pick one notation as your source of truth instead of bouncing a value back and forth.

Does it support the modern space-separated rgb() and hsl() syntax?

Yes. Both comma-separated (rgb(255, 0, 0)) and CSS Color 4 space-separated forms with a slash alpha (rgb(255 0 0 / 0.5)) are accepted, as are percentage channels like rgb(100%, 0%, 0%).

What happens to a #RGB shorthand color?

Three- and four-digit hex codes are expanded by doubling each digit, so #f0a becomes #ff00aa. Shorthand can only express 4,096 colors, so the tool always outputs the full six- or eight-digit form.

Is my color data sent to a server?

No. Parsing and conversion happen entirely in your browser with no network requests, so it works offline and nothing you paste ever leaves your machine.