Interested in sponsoring? Reach out to discuss placements.
Hex to HSL Converter
Convert hex to hsl() syntax.
Last updated: June 2026
hsl(210, 50%, 40%)
Guide
Introduction
RGB tells you how much red, green, and blue light a color contains — precise for machines, awkward for humans tuning a theme. HSL (hue, saturation, lightness) separates the color wheel position from how vivid and how bright a color appears. When you need to darken a brand blue for a hover state without shifting its hue, or build a cohesive palette by rotating hue while holding saturation constant, HSL is the intuitive model.
Certoflow's Hex to HSL Converter parses #RRGGBB input and outputs CSS-ready hsl(h, s%, l%) strings with a live preview. All math runs locally in your browser — no color data uploads. Light and dark theme support keeps sliders and swatches readable during theme engineering sessions.
What this tool does
| Feature | Behavior |
|---|---|
| Input | Hex color #RRGGBB or 3-digit shorthand |
| Output | hsl(hue, saturation%, lightness%) |
| Preview | Live swatch reflecting parsed color |
| Copy | One-click export of hsl string |
| Validation | Clear errors for malformed hex |
Hue ranges 0–360 degrees. Saturation and lightness range 0–100 percent, matching CSS Color Level 3 conventions.
How it works
Conversion follows the standard two-step pipeline defined in CSS specifications:
- Parse hex to RGB channels (0–255)
- Convert RGB to HSL using relative sRGB normalization
// Simplified: hex → RGB → HSL
const { r, g, b } = parseHex("#3b82f6");
const { h, s, l } = rgbToHsl(r, g, b);
// → hsl(217, 91%, 60%)
The algorithm computes min/max normalized channel values, derives lightness as their average, calculates saturation from the spread between min and max, and determines hue from which channel dominates. Achromatic colors (grays) produce saturation 0 with hue 0.
Certoflow uses the same rgbToHsl function shared across HSL to Hex, Complementary Color Generator, and Color Shades Generator — ensuring consistent results across the category.
Example conversions:
| Hex | HSL output |
|---|---|
#000000 | hsl(0, 0%, 0%) |
#ffffff | hsl(0, 0%, 100%) |
#ff0000 | hsl(0, 100%, 50%) |
#00ff00 | hsl(120, 100%, 50%) |
#3b82f6 | hsl(217, 91%, 60%) |
Real-world examples
Theme token documentation
Document primary brand color as both hex and HSL: #2563eb = hsl(221, 83%, 53%). Engineers adjusting hover states reduce lightness by 10% in HSL without touching hue.
Generating accessible variants
Convert text color hex to HSL, increase lightness for dark mode variant while preserving hue and saturation relationships. Verify with Color Contrast Checker.
Understanding complementary relationships
Before using Complementary Color Generator, inspect base color HSL. Complement rotates hue by 180 degrees — seeing the base hue clarifies why the output looks related yet distinct.
CSS custom property authoring
:root {
--primary: hsl(217, 91%, 60%);
}
Paste hex from design, copy HSL output, embed directly in stylesheets where HSL manipulation (hsl(from var(--primary) h s calc(l - 10%))) is planned for modern browsers.
Debugging washed-out colors
A color looks grayish despite high hex values. HSL output reveals low saturation — the issue is vividness, not lightness. Increase saturation in HSL to Hex rather than tweaking RGB blindly.
Common mistakes
Confusing HSL with HSV. Photoshop "HSB" uses value instead of lightness. HSV and HSL produce different hex results for the same intuitive slider positions. Certoflow implements CSS HSL only.
Expecting hue to matter at zero saturation. Grays (#808080) return hsl(0, 0%, 50%). Hue is undefined for achromatic colors; CSS reports 0.
Rounding differences across tools. One-degree hue variance between tools is normal from floating-point rounding. Certoflow rounds hue to integers and saturation/lightness to whole percents.
Using HSL from non-sRGB sources. Print CMYK conversions imported as hex may not match designer intent. Verify against original sRGB swatches.
Ignoring lightness when checking contrast. Two colors can share hue and saturation but differ in lightness enough to pass WCAG. Always run Color Contrast Checker for text.
Parsing HSL with wrong units. CSS requires % suffix on saturation and lightness. Certoflow output includes them — copy directly without editing.
Related tools
Color category:
- HSL to Hex — reverse conversion from HSL to hex
- Hex to RGB — channel-level RGB output
- Color Shades Generator — tint and shade palettes from base hex
- Complementary Color Generator — hue rotation by 180 degrees
- CSS Gradient Generator — build gradients from hex stops
Cross-category:
- CSS Formatter — format stylesheets with hsl values
- Image Color Picker — sample hex from images before converting
Directory at /color.
FAQ
Is conversion done locally?
Yes. All hex parsing and HSL math runs in JavaScript without network requests.
Does output match browser hsl() rendering?
Yes. Certoflow follows CSS Color Level 3 HSL-to-RGB algorithms aligned with major browsers.
Can I input rgba or rgb strings?
This tool accepts hex input. Convert rgb to hex first with RGB to Hex, or use hex from Hex to RGB workflow in reverse.
Does it support 3-digit hex?
Yes. #f00 expands to #ff0000 before conversion.
Why use HSL over RGB for theming?
HSL decouples hue from brightness adjustments — one slider change produces predictable visual results for UI states.
Offline support?
Yes, after page load.
Dark mode?
Yes. Certoflow supports light and dark themes.
HSL vs HSV — which does CSS use?
CSS uses HSL. HSV is common in graphics software but not valid CSS syntax.
Can I copy hsl() into Tailwind?
Tailwind v3+ supports arbitrary values: bg-[hsl(217,91%,60%)]. Copy Certoflow output directly.
How does this relate to LCH or OKLCH?
Certoflow currently outputs HSL. Future tools may add perceptual color spaces; HSL remains widely supported across browsers.
Frequently Asked Questions
- Why use HSL over RGB?
- HSL separates hue from saturation and lightness — easier for theme tweaks.
- Is output CSS-ready?
- Yes. Copy hsl(h, s%, l%) directly into stylesheets.
People also use
Related tools that complement this workflow.
HSL to Hex Converter
Convert HSL to hex color codes.
Color ToolsHex to RGB Converter
Convert #hex to rgb() values.
Color ToolsColor Shades Generator
Create tints and shades from one color.
Color ToolsCSS Gradient Generator
Generate linear-gradient CSS.
Developer ToolsCSS Formatter
Format and indent CSS stylesheets.
Interested in sponsoring? Reach out to discuss placements.