HSLA to HEXA Converter

Convert hsla(h, s, l, a) values into HEXA color codes without writing any intermediate helpers. This converter is handy when you define palettes in HSLA but want to store final tokens as #RRGGBBAA.

Enter a color in HSLA format and you will see the matching HEXA string immediately. You can then paste it into your design system, configuration files, or documentation.

On this page you will also find a short overview of HSLA and HEXA, a clear description of the conversion algorithm, a step-by-step example, a reference table, and a FAQ about when each format works best.

What Is HSLA

HSLA is the HSL model with an alpha channel. It is written as hsla(h, s, l, a), where h is hue in degrees, s is saturation, l is lightness, and a is opacity.

Hue ranges from 0 to 360 degrees. Saturation and lightness are percentages from 0% to 100%. Alpha is a fraction from 0 (fully transparent) to 1 (fully opaque).

HSLA is comfortable for designing palettes and themes because you can adjust hue, saturation, lightness, and alpha separately in a way that closely matches how designers talk about color.

What Is a HEXA Color Code

A HEXA code is an eight digit HEX color that includes transparency. The format is #RRGGBBAA, where each pair of characters represents red, green, blue, or alpha.

Each pair is a hexadecimal number from 00 to FF. The first three pairs work exactly like a regular HEX color, while the last pair encodes the alpha channel: 00 for fully transparent and FF for fully opaque.

Browsers and graphics tools read each pair, convert it to decimal, and treat the result as RGBA channel values. HEXA is therefore a compact textual wrapper around RGBA data.

HSLA to HEXA Conversion Formula

hsla(h, s, l, a) -> #RRGGBBAA

Given:
  h in [0, 360)
  s in [0, 100]
  l in [0, 100]
  a in [0, 1]

1) Clamp inputs:
   h_c = h
   s_c = clamp(s, 0, 100)
   l_c = clamp(l, 0, 100)
   a_c = clamp(a, 0, 1)

2) Normalize saturation and lightness:
   s' = s_c / 100
   l' = l_c / 100

3) Compute chroma:
   c = (1 - |2 * l' - 1|) * s'

4) Helper value:
   x = c * (1 - |((h_c / 60) mod 2) - 1|)

5) Temporary rgb triple in [0, c]:
   if      0 <= h_c < 60   then (r1, g1, b1) = (c, x, 0)
   else if 60 <= h_c < 120 then (r1, g1, b1) = (x, c, 0)
   else if 120 <= h_c < 180 then (r1, g1, b1) = (0, c, x)
   else if 180 <= h_c < 240 then (r1, g1, b1) = (0, x, c)
   else if 240 <= h_c < 300 then (r1, g1, b1) = (x, 0, c)
   else                      (r1, g1, b1) = (c, 0, x)

6) Add the lightness offset:
   m  = l' - c / 2
   r' = r1 + m
   g' = g1 + m
   b' = b1 + m

7) Scale to integer RGB:
   r = round(r' * 255)
   g = round(g' * 255)
   b = round(b' * 255)

8) Convert channels to HEX:
   RR = dec_to_hex(clamp(r, 0, 255))
   GG = dec_to_hex(clamp(g, 0, 255))
   BB = dec_to_hex(clamp(b, 0, 255))

9) Convert alpha to HEX:
   A_dec = round(a_c * 255)
   AA    = dec_to_hex(clamp(A_dec, 0, 255))

10) Join parts:
   #RRGGBBAA

Helpers:
   dec_to_hex(x) = to_hex(x).padStart(2, "0")
   clamp(x, min, max) = min if x < min, max if x > max, else x

In other words, the converter first turns HSLA into an RGBA color and then rewrites each channel as a two digit HEX fragment. The alpha fraction is scaled to the 0 to 255 range before being turned into the final AA pair.

Example for hsla(196, 49%, 54%, 0.8)
1) Convert HSLA to RGB:
   hsl(196, 49%, 54%) -> rgb(79, 163, 194) (rounded)
2) Convert RGB channels to HEX:
   79  -> 4F
   163 -> A3
   194 -> C2
3) Convert alpha:
   A_dec = round(0.8 * 255) = 204
   204   -> CC
4) Final HEXA:
   #4FA3C2CC

How HSLA to HEXA Conversion Works Step by Step

HSLA to HEXA conversion always passes through an RGB view of the same color. You first express hue, saturation, and lightness as numeric channels, then write those channels and alpha in hexadecimal form.

hsla(210, 39%, 17%, 0.5)
-> hsl(210, 39%, 17%)
-> rgb(r, g, b)
-> #RRGGBBAA

Here is a simplified sketch for hsla(210, 39%, 17%, 0.5).

  • Step 1 - Derive RGB from HSLA

    Ignore alpha for a moment and run the HSL to RGB algorithm: compute chroma, find the hue sector, build the temporary triple, and add the offset to match the target lightness.

    s' = 39 / 100
    l' = 17 / 100
    c = (1 - |2 * l' - 1|) * s'
    ... -> rgb(26, 43, 60) (rounded)
  • Step 2 - Convert RGB channels to HEX

    Turn each channel into a two digit HEX value, padding with a leading zero when needed so the final string always has six color digits.

    26 -> 1A
    43 -> 2B
    60 -> 3C
  • Step 3 - Encode alpha and join everything

    Multiply the alpha fraction by 255, convert the result to HEX, and concatenate all four pairs with a leading #.

    #1A2B3C80

The same pattern works for any valid HSLA color, which is why it is practical to rely on a converter or utility function rather than re doing the steps manually each time.

Choosing Between HSLA and HEXA

HSLA and HEXA both encode color and transparency, but they serve different purposes. HSLA is descriptive and slider friendly, while HEXA is compact and token friendly.

When HSLA Is a Better Fit

  • Palette and theme exploration: hue, saturation, and lightness let you move around the color space in a structured way.
  • Design documentation: HSLA values show clearly how related colors differ in saturation or lightness.
  • Communicating intent: talking about "increase lightness" or "reduce saturation" maps directly to HSLA parameters.

When HEXA Is More Practical

  • Design tokens and config: short strings such as #4FA3C2CC are easy to store and share.
  • Interop between tools: many design tools and platforms use HEX or HEXA as their default export format.
  • Static palettes: HEXA codes work well when you maintain long lists of brand and semantic colors.

Summary

Use HSLA when you plan, tweak, and discuss colors. Convert those values to HEXA when you are ready to freeze them as compact tokens for code and configuration.

Best Practices for Using HSLA and HEXA Together

It is common to work with HSLA in design contexts and HEXA in implementation. A few simple rules make this mix easy to manage.

Pick a Primary Token Format

  • Use one format as the source of truth: many teams choose HEXA for tokens or HSLA for palettes and then generate the other format automatically.
  • Avoid manual duplication: keep conversions in scripts or utilities so you do not have to update values in multiple places.

Combine With Other Models

  • Convert through RGB when needed: moving between HSLA, HEXA, RGBA, and HSV usually uses RGB under the hood, which most libraries already support.
  • Clamp generated values: when you compute new colors, always clamp hue, saturation, lightness, and alpha to their valid ranges.

Keep the System Predictable

  • Document format roles: for example, HSLA for palette specs, HEXA for shipped tokens, RGBA in low level code.
  • Use converters instead of ad hoc edits: this keeps colors consistent across all formats over time.

With clear responsibilities and automated conversions, HSLA and HEXA complement each other and keep your color system flexible and maintainable.

HSLA to HEXA Conversion Table

The following table shows several common HSLA colors with transparency and their HEXA counterparts. These values are rounded for readability; for precise work use the converter at the top of the page.

HSLA to HEXA Reference Table
DescriptionHSLAHEXA
White 50%hsla(0, 0%, 100%, 0.5)#FFFFFF80
Black 50%hsla(0, 0%, 0%, 0.5)#00000080
Red 80%hsla(0, 100%, 50%, 0.8)#FF0000CC
Green 40%hsla(120, 100%, 50%, 0.4)#00FF0066
Blue 30%hsla(240, 100%, 50%, 0.3)#0000FF4D
Yellow 60%hsla(60, 100%, 50%, 0.6)#FFFF0099
Cyan 70%hsla(180, 100%, 50%, 0.7)#00FFFFB3
Magenta 90%hsla(300, 100%, 50%, 0.9)#FF00FFE6
Overlay grayhsla(0, 0%, 7%, 0.5)#11111180
Soft grayhsla(0, 0%, 20%, 0.5)#33333380
Panel borderhsla(0, 0%, 33%, 0.5)#55555580
Accent orange 70%hsla(39, 100%, 50%, 0.7)#FFA500B3
Purple overlayhsla(300, 100%, 25%, 0.5)#80008080
Teal overlayhsla(180, 100%, 25%, 0.5)#00808080

For any other HSLA color you can use the converter at the top of the page to compute the exact HEXA string using the standard algorithm.

FAQ: HSLA to HEXA

  • Why convert HSLA to HEXA

    HSLA is easy to tweak and discuss, but HEXA is compact and widely supported as a token format. Conversion lets you keep design friendly values while shipping short, stable codes.

  • Does conversion change the actual color

    No. A correctly computed HEXA value represents the same color and transparency as the original HSLA value, up to rounding of the numeric channels.

  • What ranges do H, S, L, and A use in HSLA

    Hue is 0 to 360 degrees, saturation and lightness are 0 to 100 percent, and alpha is 0 to 1 as a fraction.

  • Can I convert HEXA back to HSLA

    Yes. You can decode HEXA to RGBA, convert RGB to HSL, and reuse the alpha value to obtain HSLA again.

  • Should tokens be stored as HSLA or HEXA

    It depends on your workflow. If you adjust palettes often, HSLA as a token format can be convenient. If you favor compact strings and cross tool compatibility, HEXA is a strong choice. Many teams store one format and generate the other automatically.

Related Converters: