SimplyCalculated.org

Color Converter — HEX, RGB & HSL

Type a hex code, pick a color visually, or edit any channel — and watch all three representations of the same color update live. No sign-up, no uploads; everything runs in your browser.

100% private: everything is processed in your browser's memory — nothing you enter is uploaded to a server, logged, or stored.

Color Converter

RGB

HSL

What Are HEX, RGB, and HSL?

Every color your screen can show is ultimately a mix of three primary channels of light: red, green, and blue. HEX, RGB, and HSL are simply three different ways of writing that same triple, and this converter lets you move between them without doing the arithmetic yourself. Understanding the differences is the key to choosing the right format for the job.

HEX

A hex color is a base-16 number split into three pairs: #3498db means red = 34 hex (52 decimal), green = 98 hex (152 decimal), blue = db hex (219 decimal). Because each pair runs from 00 to ff (0–255), a full hex color is always six digits. A shorthand form, #34d, is exactly equivalent to #3344dd — each digit is doubled, so it only works when both digits of a channel match. HEX is the compact workhorse of web development and design tools, and is what this site's own palette was chosen in.

RGB

RGB spells out the same three numbers directly, each in 0–255: rgb(52, 152, 219). It is the most literal model — there is nothing between the notation and the hardware's three light emitters — which makes it the natural choice for image editors, canvas and WebGL code, and APIs that deal in raw pixel values. Its weakness is readability: rgb(52, 152, 219) tells you almost nothing about what the color looks like.

HSL

HSL (hue, saturation, lightness) re-expresses the same triple in terms that match how people actually describe color. Hue is the position on the color wheel in degrees (0 = red, 120 = green, 240 = blue, with 360 wrapping back to red). Saturation is the intensity of the hue as a percentage (0% is gray, 100% is vivid). Lightness is how close the color is to black or white (0% is black, 50% is the pure hue, 100% is white). So hsl(204, 70%, 53%) reads as "a medium, fairly saturated blue." That semantic power is why designers use HSL for adjusting shades and tints: bumping lightness up by ten points gives a lighter version of exactly the same hue, which is much harder to reason about in RGB.

How the Conversions Work

Moving between HEX and RGB is trivial — it is just base-16 to base-10 — but converting RGB to HSL (and back) requires the formulas below, which are the same math the CSS Color specification defines. Let r, g, b be the channels scaled to 0–1, and let max and min be the largest and smallest of the three.

Quantity Formula Notes
Lightness L = (max + min) / 2 Midpoint between brightest and darkest channel
Delta Δ = max − min 0 when all channels are equal (a gray)
Saturation S = Δ / (1 − |2L − 1|) 0 for grays; grows as channels diverge
Hue 60° × f(max) f uses the dominant channel's sector; negative results wrap to 0–360

Concretely, hue depends on which channel is largest: if red dominates, hue starts from the red sector (0°) and is adjusted by how far green and blue are apart; if green dominates it starts at 120°; if blue dominates, at 240°. When all three channels are equal the color is a gray, the delta is zero, saturation is defined as 0, and hue is meaningless (this tool reports 0). Converting back from HSL to RGB runs the same formulas in reverse through the standard "hue to RGB" helper function.

Step-by-Step: Converting #3498db by Hand

Follow along once so the math never feels like magic. Start with the hex value #3498db:

  1. HEX → RGB: convert each hex pair to decimal. 34 = 52, 98 = 152, db = 219. So rgb(52, 152, 219).
  2. Scale to 0–1: divide each channel by 255, giving approximately r = 0.204, g = 0.596, b = 0.859. Here max = 0.859 (blue) and min = 0.204 (red).
  3. Lightness: L = (0.859 + 0.204) / 2 = 0.531, or 53.14%.
  4. Delta: Δ = 0.859 − 0.204 = 0.655.
  5. Saturation: S = 0.655 / (1 − |2 × 0.531 − 1|) = 0.655 / 0.938 = 0.699, or 69.87%.
  6. Hue: blue is the dominant channel, so hue starts in the blue sector: 60 × ((r − g) / Δ + 4) = 60 × ((0.204 − 0.596) / 0.655 + 4) = 60 × 3.401 = 204.07°.

Result: #3498db = rgb(52, 152, 219) = hsl(204.07, 69.87%, 53.14%) — exactly what the tool above shows. And the round trip works: plug those HSL values back into the reverse formula and you recover rgb(52, 152, 219) exactly, which is why converting a color back and forth never drifts.

Conversion Reference Table

Color HEX RGB HSL
White#ffffffrgb(255, 255, 255)hsl(0, 0%, 100%)
Black#000000rgb(0, 0, 0)hsl(0, 0%, 0%)
Red#ff0000rgb(255, 0, 0)hsl(0, 100%, 50%)
Green#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%)
Carrot orange#e67e22rgb(230, 126, 34)hsl(28.16, 79.67%, 51.76%)
Dodger blue#3498dbrgb(52, 152, 219)hsl(204.07, 69.87%, 53.14%)
Amethyst purple#9b59b6rgb(155, 89, 182)hsl(282.58, 38.91%, 53.14%)
Emerald green#2ecc71rgb(46, 204, 113)hsl(145.44, 63.2%, 49.02%)

Paste any of the HEX values above into the tool to watch all three representations appear at once, or type any other color you have on hand.

When to Use Each Format

  • HEX — the default for CSS custom properties, design tokens, brand style guides, and copying between design tools. Compact and unambiguous.
  • RGB — anywhere raw pixel values are the interface: canvas/WebGL drawing, image processing, data visualization libraries, and APIs that return or accept channel triples.
  • HSL — when you are generating color systems programmatically. A ramp of ten shades is trivially produced by stepping lightness while holding hue and saturation constant, which is exactly how the site's palette generator works. HSL is also the best format for "make this a bit softer" edits.

Troubleshooting & Common Mistakes

Invalid hex input

The converter accepts only three- or six-digit hex (with or without the leading #). The usual mistakes: accidentally copying the 0x-prefixed form from code (e.g. 0x3498db), mixing in non-hex characters, or pasting an eight-digit hex with an alpha pair (#3498db80) — strip the final two digits first. The tool shows a clear error instead of guessing, so the moment the field turns red you know exactly what to fix.

Confusing HSL with HSB/HSV

As covered in the FAQ, HSL and HSB share a hue circle but differ in the third axis. If you are converting a color that came from a tool labeled HSB or HSV, do not assume the numbers are interchangeable — convert deliberately between the two models, or you will get visibly different colors.

Rounding when you don't need to

This tool rounds HSL to two decimals so the display stays tidy, but the underlying conversion is exact and round-trips cleanly. If you hand-type rounded HSL values back into CSS you may see a one-unit shift in a channel; that is unavoidable rounding, not a bug in the tool.

Frequently Asked Questions

Which color format should I use — HEX, RGB, or HSL?
It depends on what you are doing. HEX is the compact shorthand that design tools, brand guidelines, and front-end code most often use, so it is the best format for copying a color between Figma, Photoshop, a style guide, and CSS. RGB is useful when a tool expects three channel numbers (0–255) — image editors, canvas/WebGL code, and many native APIs work this way. HSL is the most human-readable of the three: once you know hue, saturation, and lightness, you can reason about a color without looking at it, and it is the format that makes adjustments like "slightly less saturated" or "a darker shade of the same hue" trivial. There is no wrong answer — this tool keeps all three in sync so you can copy whichever one the destination needs.
Does HEX support transparency like rgba() and hsla() do?
HEX does support alpha, in an 8-digit form: #rrggbbaa, where the final two digits are the alpha channel (00 = fully transparent, ff = fully opaque). This tool deliberately works with the three-digit/opaque six-digit forms because the RGB and HSL views it synchronizes have no alpha channel. If you need transparency, convert your opaque color here and then add the alpha to whichever format you need — for example rgba(52, 152, 219, 0.5) or an 8-digit hex like #3498db80. CSS also accepts the modern space-separated syntaxes rgb(52 152 219 / 50%) and hsl(204 70% 53% / 50%).
Why do my colors look slightly different on another screen?
The numbers are exact, but the way a screen renders them is not — monitor calibration, color gamut (sRGB vs. Display P3 vs. wide gamut), brightness settings, and even viewing angle all shift the perceived result. A hex code like #3498db is a precise instruction inside the sRGB color space, which is the standard for web content, but a display can only reproduce it as well as its own hardware allows. This is normal and expected: check your design on a calibrated display, and if brand colors matter, verify them against the official swatch rather than relying on any single monitor.
Is this converter accurate for the exact same value as CSS?
Yes. This tool implements the same RGB↔HSL conversion math defined in the CSS Color Module (the sRGB formulas from the CSS Color 4 specification) and rounds the HSL output to two decimal places for readability. If you take the HSL values it produces and put them back into CSS as hsl(204.07, 69.87%, 53.14%), the browser will render a color that is visually indistinguishable from #3498db — the round trip back to RGB recovers the original channels exactly, as the worked example above demonstrates.
What is the difference between HSL and HSB/HSV?
They are two different ways of arranging the same three dimensions. HSL (hue, saturation, lightness) is a cylinder where lightness runs from pure black to pure white through the color; HSB/HSV (hue, saturation, brightness/value) is a cone where value runs from black to the fully saturated color. Both share the same hue circle, but a "100% saturated" color means something different in each model — in HSB a fully saturated bright red is at 100% value, while in HSL the same red sits at 50% lightness. Tools like Photoshop call the HSB model HSB; CSS and this converter use HSL. If you are copying values between the two, convert deliberately rather than assuming the numbers mean the same thing.
Does this tool send my colors to a server?
No. The conversion happens entirely in your browser using plain JavaScript — nothing you type is uploaded, logged, or stored anywhere. You can paste brand colors, design tokens, or anything else with complete privacy, and even use the page offline after it has loaded.

Formula last verified August 22, 2026 against our published methodology .