๐ŸŽจ Color Converter (HEX/RGB/HSL)

Last updated: April 14, 2026
Color Converter
HEX ยท RGB ยท HSL ยท HSV โ€” live preview + copy
Current Color
#3B82F6
White โ˜… Black โ˜…
HEX
#
Invalid HEX โ€” use 3 or 6 hex characters
RGB
R
G
B
R 59
G 130
B 246
HSL
H
S
L
HSV
H
S
V
All Formats
HEX
#3B82F6
RGB
rgb(59, 130, 246)
HSL
hsl(217, 91%, 60%)
HSV
hsv(217, 76%, 96%)
CSS HSL
hsl(217deg 91% 60%)
RGB %
23.1% 51% 96.5%

Why Color Format Conversions Still Trip Up Developers in 2025

Every front-end developer hits this wall at least once a week: your designer hands you a color in HEX from Figma, your CSS custom property needs HSL, and the Tailwind config wants RGB percentages. Copying numbers from one format to another by hand is how bugs slip through โ€” a transposed digit in a six-character hex code turns your brand blue into hospital green, and you won't notice until QA catches it in staging.

Color conversion math is deceptively simple-looking but surprisingly easy to get wrong, especially around edge cases. HSL and HSV share the same Hue axis but calculate Saturation completely differently. Many developers assume the two S values are interchangeable โ€” they're not, and the visual difference between hsl(220, 80%, 60%) and the naively-converted HSV equivalent is immediately obvious on screen.

HEX โ€” The Format Designers Love and Computers Tolerate

Hexadecimal color notation (#RRGGBB) maps each channel to a two-digit base-16 number, giving you 256 possible values per channel. The shorthand form (#RGB) is a 4-bit approximation โ€” #F06 expands to #FF0066, not #F00066. This is a common source of confusion: shorthand is lossy. If your brand color is #FA0062, shorthand simply cannot represent it accurately. The 3-digit form exists because early monitors couldn't render the full 24-bit range; today it's mostly a convenience for solid pastel or web-safe palettes.

HEX is case-insensitive, so #3b82f6 and #3B82F6 are identical. Most design tools output uppercase; most browser dev tools output lowercase. Neither convention is wrong, but picking one and sticking with it in your codebase avoids meaningless diffs in version control.

RGB โ€” The Model Your Monitor Actually Uses

Red, Green, Blue channels each run from 0 to 255 (8 bits). This is the native language of your display hardware โ€” every pixel is literally three tiny lights. When you're doing any kind of image manipulation, blending, or Canvas-based drawing in JavaScript, you're working in RGB whether you realize it or not. The CanvasRenderingContext2D API, WebGL, and most media processing pipelines all speak RGB.

One thing CSS developers sometimes overlook: rgb() in modern CSS also accepts percentage values and even channel values above 255 for wide-gamut displays. The color() function introduced in CSS Color Level 4 takes display-p3 values that can be negative or greater than 1. For everyday web work this won't matter, but if you're building tools for photo editing or print-adjacent workflows, it's worth knowing the boundaries of standard sRGB.

HSL โ€” The Format Your Brain Actually Prefers

Hue, Saturation, Lightness maps much more closely to how humans think about color. Want a lighter version of your brand color? Bump up the L value. Want a less saturated, more muted tone? Reduce S. Want the complementary color? Add 180 degrees to H. None of these operations are intuitive in HEX or RGB โ€” you'd have to do separate arithmetic on all three channels.

CSS has supported HSL since 2010, but many developers still reflexively reach for HEX. The newer hsl() syntax in CSS Color Level 4 drops the commas: hsl(220deg 91% 60%) โ€” and also accepts the unitless hue hsl(220 91% 60%). Both are valid in every modern browser, but older tooling (including some PostCSS plugins and legacy autoprefixers) may balk at the space-separated form.

One HSL gotcha worth knowing: at 0% or 100% Lightness, the Saturation value becomes meaningless โ€” pure black and pure white have no hue, so the S value is essentially undefined. Different tools will display different S numbers for these edge cases even when the rendered color is identical.

HSV โ€” The Format Photoshop Taught You

HSV (also called HSB โ€” Hue, Saturation, Brightness) is what the Adobe color picker uses. Value/Brightness represents the intensity of the light source, while Lightness in HSL represents the midpoint between black and white. The practical difference: in HSV, a fully saturated red at 100% Value is rgb(255, 0, 0). In HSL, a fully saturated red at 50% Lightness is also rgb(255, 0, 0). But at 100% Lightness in HSL you get pure white regardless of Hue โ€” while in HSV, 100% Value with 0% Saturation gives you white.

If you're building a color picker from scratch or working with creative tools, HSV tends to produce more intuitive UX because increasing V always makes things brighter without muddying toward gray. HSL's Lightness scale runs from black through the pure hue to white, which makes it feel less predictable for creative workflows even though it's mathematically elegant.

Quick Tips for Working With Color Conversions in Code

When writing your own conversion functions, watch out for floating-point drift. The HSL-to-RGB path through intermediate floating-point math can produce rgb(255, 0, 1) instead of rgb(255, 0, 0) if you round at the wrong step. Always clamp your output to [0, 255] after rounding, not before.

For HSL and HSV, the Hue value wraps at 360 degrees โ€” so 361ยฐ is the same as 1ยฐ. If you're interpolating between two hues for an animation, always check whether going "the short way" around the wheel is shorter than going directly. Interpolating from 350ยฐ to 10ยฐ should travel 20ยฐ, not 340ยฐ.

WCAG contrast ratios are calculated from relative luminance, not from any of the HSL/HSV/RGB values directly. Luminance uses a gamma-corrected linearization of each RGB channel before weighting them (Rร—0.2126 + Gร—0.7152 + Bร—0.0722). That's why a pure yellow (#FFFF00) has extremely high contrast against black but terrible contrast against white, even though it looks "bright" in both HSL and HSV models. Always verify contrast programmatically โ€” visual intuition alone is not reliable.

Finally: CSS custom properties and HSL are a powerful combination for theming. Define your palette as a set of hue values, then generate tints and shades by varying L and S. This lets you switch an entire theme's mood by changing a single hue variable at the root level โ€” far more maintainable than tracking down dozens of hardcoded hex values scattered through a stylesheet.

FAQ

What is the difference between HSL and HSV?
Both use the same Hue axis (0โ€“360ยฐ), but they model brightness differently. HSL (Lightness) runs from black at 0% through the pure color at 50% to white at 100%. HSV (Value/Brightness) runs from black at 0% to the pure hue at 100% โ€” there is no white at the top of the Value scale unless Saturation is also 0%. Photoshop and most creative tool color pickers use HSV; CSS uses HSL.
Can I use HSL values directly in CSS?
Yes. CSS has supported hsl() since 2010. Modern CSS Color Level 4 syntax allows both comma-separated (hsl(220, 91%, 60%)) and space-separated (hsl(220deg 91% 60%)) forms. Both work in all current browsers. The space-separated form also supports an optional alpha channel: hsl(220 91% 60% / 0.5).
Why does shorthand HEX (#RGB) sometimes look different from the full form?
The 3-digit shorthand #RGB is shorthand for #RRGGBB by doubling each digit. So #F06 expands to #FF0066, not #F00066. This means shorthand can only represent colors where both hex digits of each channel are the same (00, 11, 22, ..., FF). If your target color is #FA0062, shorthand simply cannot represent it accurately and you must use the full 6-digit form.
How do I convert HEX to RGB manually?
Split the 6-character hex code into three pairs: RR, GG, BB. Convert each pair from base-16 to base-10. For #3B82F6: 3B = 59, 82 = 130, F6 = 246, giving rgb(59, 130, 246). Most programming languages have parseInt(hexStr, 16) or equivalent for this conversion.
Why do WCAG contrast ratios matter for color conversion tools?
WCAG (Web Content Accessibility Guidelines) require a minimum contrast ratio of 4.5:1 for normal text and 3:1 for large text between foreground and background colors. When you pick or convert a color, checking its contrast against both black and white text immediately tells you which text color will be accessible on that background โ€” saving an extra trip to a separate contrast checker.
What is the most accurate way to round values during color conversion to avoid drift?
Perform all intermediate calculations in floating-point, then round and clamp only at the final output step. Rounding intermediate HSL or RGB values introduces cumulative error that compounds across multiple conversions. For example: converting HEX โ†’ RGB โ†’ HSL โ†’ RGB should return values within ยฑ1 of the original if you round only at the final RGB step.