HSL to Hex Converter
The HSL to Hex Converter takes the hue, saturation, and lightness values you enter into HSL Input (H, S%, L%) and calculates the matching hex color. Click Convert and your code appears in Hex Output, with an uppercase option for the letters. Use the octal to hex converter to translate an octal permission code or value straight into hex without doing the math by hand.
What Is the HSL Color Model and Why Does It Matter for the hsl to hex converter?
The hsl (hue, saturation, lightness) color model is a cylindrical representation of the rgb color model, developed in the 1970s by computer graphics researchers to align more naturally with the way human vision perceives tone through color perception. Rather than mixing raw channel intensities like RGB, HSL describes a shade by three intuitive dimensions — the color making attributes — that map directly to how designers and artists think about color theory. Since Pantone doesn't publish an official hex mapping, the hex to pantone converter instead compares your color against a curated approximation list.
Hue, Saturation, and Lightness — the Three hex-Producing Inputs Explained
In the HSL scheme, each shade lives inside a cylinder. Imagine slicing that cylinder into a radial slice: the angle around the central axis is the tonal angle (h), measured from 0–360°, where 0° and 360° are both red, 120° is green, and 240° is blue. The distance from the central axis is the chromatic intensity (s), expressed as 0–100%, where 0% yields neutral colors (grays) and 100% yields fully vivid tones. The height along the axis is the perceptual brightness (l), also 0–100%, running from pure black at 0% to pure white at 100%, with a true mid-tone at 50%. Understanding these tonal components is the foundation of every hsl to hex translation.
How HSL Differs from RGB and Hex — and Why Both Still Matter
The RGB (red green blue) model defines a digital color by mixing three channel intensities from 0 to 255, making it precise for rendering but opaque for scheme-building. A hex triplet like #3b82f6 is simply a compact hexadecimal notation of the same three channels — equivalent to rgb(59, 130, 246) in RGB, hsl(217, 91%, 60%) in HSL, and oklch(64% 0.2 259) in OKLCH — confirming that all these are just alternative representations of one underlying tonal value. HSL is human-readable and supports intuitive adjustments: bumping the brightness level by 10% always produces a predictably lighter shade, giving you predictable contrast across your scheme. Hex is machine-friendly and offers wide acceptance across every browser, styling tool, and legacy project. Stylesheet syntax natively supports both hsl() notation and markup hex notation, so choosing between them is a matter of workflow context rather than technical limitation.
What Is a Hex Color Code? A color converter Primer on the #RRGGBB Format
A hex color code — sometimes called a hex triplet — is a three-byte, six-digit hexadecimal number prefixed with a hash symbol, used in markup, stylesheets, scalable vector graphics, and other computing applications to define a web color. Each pair of digits encodes one of the three red green blue channel components in hexadecimal notation, ranging from 00 to FF (equivalent to 00 to ff in decimal notation 0–255). Understanding this structure makes tonal translation far more transparent. If you're debugging register values and don't want to convert to decimal by hand, the hex calculator does the arithmetic for you.
Breaking Down the #RRGGBB Hex Format — Red, Green, and Blue Channel Values
| Position | Digits | Channel | Range | Example (#FF6600) |
|---|---|---|---|---|
| 1–2 | RR | Red | 00–FF | FF = 255 (full red) |
| 3–4 | GG | Green | 00–FF | 66 = 102 (mid green) |
| 5–6 | BB | Blue | 00–FF | 00 = 0 (no blue) |
This #RRGGBB structure means every legal tonal value encodes exactly one byte per channel. The markup specification, modern stylesheet syntax, and scalable vector graphics definitions all rely on this same six-digit hexadecimal format, making hex the single most universally recognized tonal representation across front-end tooling.
Shorthand Hex Codes — When #ABC Is a Valid hex input
Stylesheet syntax also accepts a shorthand hex code in the form #ABC, where each single digit is doubled to produce the full six-digit equivalent #AABBCC. For example, #F00 expands to #FF0000 (pure red), and #08F becomes #0088FF. The hexadecimal shorthand is convenient for shades whose channels happen to share identical nibbles, but the full #RRGGBB format is always unambiguous. If your tool receives a shorthand hex entry containing non-hex characters or an incorrect digit count, a well-implemented color converter will flag the error clearly rather than silently producing an incorrect result.
Using This hsl to hex converter — Inputs, Output, and the Live Preview
This hsl to hex converter is designed to be simple to use and a fast tool for any front-end workflow. Enter your three hsl values and the result appears instantly as a copyable hex string alongside a live tonal swatch. Type a Benjamin Moore paint name into the benjamin moore to hex converter and it returns an approximate hex code drawn from a curated list, not official data.
Step-by-Step Input Guide for Accurate Color Conversions
- Enter Hue: Type a value from 0 to 360 into the Hue field. This sets the position on the chromatic spectrum, determining which family of tones (red, orange, yellow, green, blue, violet) the result belongs to.
- Enter Saturation: Type a percentage from 0 to 100. At 0% you get a neutral gray; at 100% you get the most vivid version of that tonal angle.
- Enter Lightness: Type a percentage from 0 to 100. Values below 50% darken toward black; values above 50% brighten toward white.
- Read the hex output: The converter immediately displays the corresponding
#RRGGBBhex string and a tonal swatch so you can verify the result visually. - Copy the result: Click the copy icon to transfer the hex output directly to your clipboard, ready for your stylesheet, style tokens, or developer handoff document.
If you enter a value outside the valid range — for instance, a tonal angle above 360 or a chromatic intensity below 0 — the tool clamps or flags the input so you never receive a corrupted output. This makes it reliable even in rapid iteration during UI work and scheme building.
The Math Behind hsl to hex Conversion — From Cylinders to Hex Strings
Every hsl to hex translation is a two-stage process: first convert HSL to red-green-blue components, then encode those components into their hexadecimal equivalents. Understanding both stages gives you confidence in the output and the ability to verify results independently.
Converting HSL to RGB — the Chroma and Intermediate Value Formula
Given normalized values where chromatic intensity (s) and perceptual brightness (l) are expressed as decimals (0–1) and the tonal angle (h) is in degrees (0–360), the algorithm proceeds as follows:
First, compute the chroma (the range of the output):
$$C = (1 - |2L - 1|) imes S$$Then find the intermediate value X based on the tonal sector:
$$X = C \times \left(1 - \left|\left(\frac{H}{60} \bmod 2\right) - 1\right|\right)$$The minimum (offset) component is:
$$m = L - \frac{C}{2}$$Depending on which 60° sector the tonal angle falls in, assign preliminary (R₁, G₁, B₁) values:
- 0° ≤ H < 60°: (C, X, 0)
- 60° ≤ H < 120°: (X, C, 0)
- 120° ≤ H < 180°: (0, C, X)
- 180° ≤ H < 240°: (0, X, C)
- 240° ≤ H < 300°: (X, 0, C)
- 300° ≤ H < 360°: (C, 0, X)
Finally, add the offset to get the true red-green-blue components scaled to 0 to 255:
$$R = \text{round}((R_1 + m) \times 255), \quad G = \text{round}((G_1 + m) \times 255), \quad B = \text{round}((B_1 + m) \times 255)$$Converting RGB Values to a Hex Code — Encoding Each Channel
Once you have integer red-green-blue components in the 0–255 range, the step to a hex string is straightforward. Each component is individually converted to a two-digit hexadecimal number, padding with a leading zero if necessary, and the three pairs are concatenated:
$$\text{Hex} = \text{"\#"} + \text{toHex}(R) + \text{toHex}(G) + \text{toHex}(B)$$Where toHex(n) converts an integer 0–255 to a two-character hexadecimal string (e.g. 15 → 0F, 255 → FF). This rgb to hex step is why low-channel values like those in navy blue require zero-padding to maintain the valid #RRGGBB structure.
Worked Example 1 — hsl(60, 100%, 50%) Converts to #FFFF00 (Pure Yellow)
- Normalize inputs: H = 60, S = 1.0, L = 0.5
- Calculate chroma: \(C = (1 - |2 \times 0.5 - 1|) \times 1.0 = 1.0\)
- Find X: \(X = 1.0 \times (1 - |(60/60 \bmod 2) - 1|) = 1.0 \times (1 - |1 - 1|) = 1.0\)
- Hue sector 0–60°: \((R_1, G_1, B_1) = (1.0, 1.0, 0)\)
- Offset: \(m = 0.5 - 0.5 = 0\)
- Scale to 255: \(R = 255, G = 255, B = 0\)
- Encode as hex:
#FFFF00— pure yellow#FFFF00confirmed.
Worked Example 2 — hsl(120, 33%, 62%) Converts to #7FBF7F (Muted Green)
- Normalize: H = 120, S = 0.33, L = 0.62
- Chroma: \(C = (1 - |2 \times 0.62 - 1|) \times 0.33 = (1 - 0.24) \times 0.33 = 0.76 \times 0.33 \approx 0.2508\)
- X: \(X = 0.2508 \times (1 - |(120/60 \bmod 2) - 1|) = 0.2508 \times (1 - |0|) = 0.2508\)
- Hue sector 120°: \((R_1, G_1, B_1) = (0, 0.2508, 0)\) — wait, at exactly 120° the sector is (0, C, X): \((0, 0.2508, 0.2508)\)
- Offset: \(m = 0.62 - 0.1254 = 0.4946\)
- Scale: \(R = \text{round}(0.4946 \times 255) = 126 \approx \text{7F}\), \(G = \text{round}(0.7454 \times 255) = 190 \approx \text{BE}\rightarrow\text{BF}\), \(B = 126 \approx \text{7F}\)
- Result:
#7FBF7F— a soft, muted green typical of status tones and nature-themed schemes.
Worked Example 3 — hsl(240, 100%, 25%) Converts to #000080 (Navy Blue)
- Normalize: H = 240, S = 1.0, L = 0.25
- Chroma: \(C = (1 - |2 \times 0.25 - 1|) \times 1.0 = (1 - 0.5) \times 1.0 = 0.5\)
- X: \(X = 0.5 \times (1 - |(240/60 \bmod 2) - 1|) = 0.5 \times (1 - |0 - 1|) = 0.5 \times 0 = 0\)
- Hue sector 240–300°: \((R_1, G_1, B_1) = (X, 0, C) = (0, 0, 0.5)\)
- Offset: \(m = 0.25 - 0.25 = 0\)
- Scale: \(R = 0 \rightarrow \text{00}\), \(G = 0 \rightarrow \text{00}\), \(B = \text{round}(0.5 \times 255) = 128 \rightarrow \text{80}\)
- Result:
#000080— classic navy blue. The zero-padding on the red and green channels is essential; without it, the output would be an invalid hex entry.
Example hsl to hex Conversions — Common Color Reference Table
The table below provides a ready reference of frequent hsl values alongside their hex equivalents, covering a broad sweep of tonal combinations you will encounter in real creative digital projects.
| Scenario | HSL Value | Hex Code | Visual Notes / Use Case | Why It Matters |
|---|---|---|---|---|
| Pure Red | hsl(0, 100%, 50%) | #FF0000 | Maximum chroma red; used for alerts and brand colors | Confirms zero-offset chroma output; #ff0000 is the red benchmark |
| Pure Yellow | hsl(60, 100%, 50%) | #FFFF00 | Full-intensity warm yellow; ideal for highlights and warnings | Both RR and GG channels max out — validates sector logic |
| Muted Green | hsl(120, 33%, 62%) | #7FBF7F | Soft green for nature themes and success status colors | Tests mid-range chromatic intensity and brightness handling |
| Navy Blue | hsl(240, 100%, 25%) | #000080 | Dark, rich blue for corporate branding and headers | Low brightness produces small hex channel components needing zero-padding |
| Pure White | hsl(0, 0%, 100%) | #FFFFFF | Background and typography baseline | All channels at maximum FF; chromatic intensity is irrelevant at full brightness |
| Pure Black | hsl(0, 0%, 0%) | #000000 | Absolute dark; used for text, shadows | All channels zero; confirms offset calculation at zero brightness |
| Mid Gray | hsl(0, 0%, 50%) | #808080 | Neutral mid-tone for backgrounds and UI schemes | Zero chromatic intensity yields identical channel components — true neutral gray |
Tips for Working with HSL and Hex in Digital Projects — Best Practices for hsl color conversion
Knowing when to stay in hsl versus when to reach for a hex string is a practical tonal-management skill that separates efficient front-end workflows from fragile ones. Good awareness of color perception here can save hours of rework during creative iteration.
When to Use HSL in Your Stylesheet Styling and Style Frameworks
- Use hsl in stylesheets when building component libraries — adjusting only the brightness channel generates consistent shades and tints for shade scales without touching the core tonal angle.
- Use stylesheet custom properties with HSL components to enable theme switching: one variable change can shift your entire scheme from light to dark mode with predictable contrast.
- HSL makes tonal adjustments and tonal manipulation straightforward — creating complementary tones is as simple as adding 180° to the angular value.
- For accessible schemes, tweak the brightness channel to hit WCAG contrast ratios while preserving creative intent — this is scheme fine-tuning at its most ergonomic.
- Tonal arrangement and UI scheme generation tools like a shade generator frequently output HSL because it maps directly to perceptual brightness steps.
When Hex Codes Are the Better Choice for Developer Handoff
- Use hex strings when handing assets off through a brand guide or exporting from creative applications like Figma — most creative applications default to hex output.
- Hex is the recommended format for legacy projects where styling is already structured around #RRGGBB values and refactoring would introduce risk.
- For developer handoff documents and style tokens, a hex string is universally parseable by every tone selector, preprocessor, and developer tools panel without any translation overhead.
- Scalable vector graphics files and markup email templates often require hex notation rather than
hsl()for wide acceptance across older rendering engines. - When sharing a specific tonal identifier via a toolbox, URL parameter, or API, hex is compact and unambiguous — ideal for modern digital-project communication.
Related Color Tools You May Find Useful — Expand Your color converter Toolbox
Accurate tonal translations rarely happen in isolation. The tools below complement this hsl to hex color converter and cover the full range of tonal notations you will encounter across digital creative and front-end workflows. Use them together to maintain consistent tonal representation across every color space your project touches.
Color Format Converters — Covering Every Color Space Direction
- Hex to HSL Converter — the reverse of this tool; use it when you need to move a hex shade back into the HSL model for scheme fine-tuning. Also known as convert hex to hsl.
- Hex to HSV Converter — translates a hex shade to HSV (hue-saturation-value), the format used in many tone-selector interfaces and some creative software.
- Hex to RGB — extracts the red, green, and blue components from any hex shade; useful when feeding values into canvas or WebGL APIs.
- Hex to CMYK Converter — converts a hex shade to CMYK for print production workflows where ink channels replace light channels.
- CMYK to Hex Converter — brings print-originated CMYK values back into web-ready hex.
- Hex to LAB — converts a hex shade to LAB, the perceptually uniform space used in advanced tonal science and accessibility analysis.
- RGB to Hex — if your source is already red-green-blue components, skip the HSL step and encode directly.
- RGB to HSL — move from the machine-native red-green-blue model into human-friendly HSL.
- HSL to RGB — isolate the first stage of the hsl to hex pipeline for use in JavaScript canvas or game engines.
- HSL to CMYK — bridge your HSL-authored scheme directly to print.
- HSL to HSV — convert between the two cylindrical representations; useful when switching between tools that use hue-saturation-value versus hue-saturation-lightness.
- HSL to LAB — step up to a perceptually even color space from your HSL source.
- Hex Calculator — perform arithmetic directly on hexadecimal values for fine-grained channel adjustments.
- HSV to Hex — convert HSV (hue-saturation-value) directly to a web-ready hex string.
- HSV to RGB — extract red-green-blue components from an HSV shade.
- HSV to HSL — toggle between cylindrical tonal-space variants.
- HSV to CMYK — send HSV creative tones to print workflows.
- HSV to LAB — analyze perceptual brightness of HSV-defined shades.
- LAB to RGB, LAB to Hex, LAB to HSL, LAB to CMYK, LAB to HSV — full coverage for LAB space tonal translations.
- RGB to CMYK, RGB to HSV, RGB to LAB — complete the red-green-blue translation matrix.
- CMYK to RGB, CMYK to HSL, CMYK to HSV, CMYK to LAB — round-trip your print tones back to screen notations.
Color Palette and Design Tools — Beyond the color converter
- Color Wheel — visualize the spectral relationships between tonal angles and build harmonious tonal arrangements and complementary pairings.
- Gradient Generator — create smooth tonal transitions between two or more shades; outputs stylesheet
linear-gradient()syntax directly. - Color Mixer — blend two web shades together and preview the result across multiple mixing ratios.
- Color Palette Builder — assemble, organize, and export complete tonal sets for component libraries and UI projects.
- Image Color Picker — extract a tonal scheme from image assets to match existing photography or brand imagery.
- Color Contrast Checker — verify WCAG readability ratios between foreground and background tones for accessibility compliance.
- Random Color Generator — generate an unexpected shade for quick prototyping, mood boarding, or creative digital exploration.
- Color Name Finder — identify the closest named label for any hex or HSL value, useful for documentation and brand communication.
- Color Palette Generator — automatically generate harmonious tonal sets from a seed shade.
- Compare Colors — place two shades side by side to evaluate perceptual similarity and tonal contrast in context.
- Shade Generator — produce a full spectrum of shades and tints from any base shade for comprehensive UI schemes and style tokens.
- Color Converter — the all-in-one color converter supporting HEX, RGB, HSL, HSV, CMYK, LAB, LCH, and OKLCH simultaneously for any-direction tonal translation.
Frequently Asked Questions About HSL to Hex Conversion and hsl color model Concepts
Q1: Can I use a shorthand hex code like #ABC?
Yes. Stylesheet syntax fully supports the shorthand hex code #ABC, which the browser automatically expands to #AABBCC. However, this converter always outputs the full six-digit hexadecimal #RRGGBB format to ensure wide acceptance with every tool and project, including those that do not support the shorthand.
Q2: What if my hex input is invalid (wrong length or invalid characters)?
A well-designed tonal tool like this one catches non-hex entries and values with an incorrect digit count before attempting translation, displaying a clear validation message. This prevents silent errors from producing a subtly wrong hex string that would be difficult to catch during stylesheet review. Always confirm the output swatch matches your intended shade visually.
Q3: Is HSL always more useful than Hex?
No — each notation has its own strengths within the broader tonal ecosystem. HSL excels at intuitive adjustments, tonal manipulation, and building accessible schemes with predictable brightness levels. Hex excels at wide acceptance, compact representation, and tonal-identifier sharing across creative applications, browsers, and legacy dependencies. For digital projects combining both — authoring in HSL and exporting hex — is the most practical approach. For even perceptual spacing beyond what HSL offers, consider LCH or OKLCH.
Q4: Can I convert the other way around — from HSL → Hex?
You are already on the hsl to hex converter, which goes from hsl() values to #RRGGBB. To reverse the process, use our dedicated hex to hsl converter. This related tool accepts any valid hex input and outputs the three HSL components instantly. The ability to go in both directions gives you full tonal-representation flexibility in your workflow.
Q5: Do browsers support HSL in stylesheets?
Yes — browser support for hsl() and hsla() syntax is universal across all modern browsers, and the hsl() function is natively part of the Color Level 3 specification. You can use HSL values directly in stylesheet rules, custom properties, and inline styles without any preprocessing. That said, hex strings retain an advantage in tools and contexts that predate Color Level 3, making the hsl to hex converter an essential bridge for multi-environment tonal values.
Which color format should I use for web design?
For modern projects, start with HSL when crafting your color palette — its consistent perceptual brightness steps make scheme-building and accessibility tuning straightforward. Export to hex for final stylesheet variables, vector assets, and developer handoff. If your team is adopting perceptual consistency as a priority, explore OKLCH as a step beyond HSL toward fully even tonal spaces. Avoid building your full web tonal system in hex alone — it provides no perceptual brightness control and makes tonal schemes harder to maintain over time.
What color formats can I convert between using these tools?
Our suite of tonal tools covers the complete matrix of notations used in digital and print work: HEX, RGB, HSL, HSV, CMYK, LAB, LCH, and OKLCH. These span every tonal space encountered in UI work, front-end development, print production, and advanced tonal science. Every pair of notations has a dedicated translator in both directions, so you can freely convert tones wherever your workflow takes you — from Figma exports to stylesheet variables to print-ready CMYK files — without manual calculation or risk of equivalent-values drift.