Home › Image Tools › HEX to HSL

HEX to HSL

Convert any HEX color to HSL and back. Paste a code like #2f6b4f, or drag the hue, saturation and lightness sliders, and copy the HSL, HEX, RGB or a ready-made CSS snippet.

Last updated:

Accepts #rgb, #rgba, #rrggbb and #rrggbbaa, with or without #.

°
%
%
%
hsl(152, 39%, 30%)#2f6b4f
HSL
HEX
RGB
HSL exact
CSS snippet

      

Lightness scale Same hue and saturation, click to load

Advertisement
Advertisement

How to use the HEX to HSL

  1. Paste a HEX code such as #2f6b4f or #fa0 and press Convert (it also converts as you type).
  2. Read the HSL value in the results, for example hsl(152, 39%, 30%), along with HEX and RGB.
  3. Adjust the color with the H, S and L sliders or number boxes; the HEX code updates instantly.
  4. Add transparency with the alpha slider to get hsla() and an 8-digit HEX.
  5. Press Copy next to any format, or copy the CSS snippet with ready-made custom properties.

HEX to HSL formula

Take #2f6b4f as an example:

  1. Split into channels and divide by 255: R = 0x2f = 47 → 0.184, G = 0x6b = 107 → 0.420, B = 0x4f = 79 → 0.310.
  2. Max = 0.420 (green), min = 0.184, difference d = 0.235.
  3. Lightness L = (max + min) ÷ 2 = 0.302 → 30%.
  4. Saturation S = d ÷ (1 − |2L − 1|) = 0.235 ÷ 0.604 = 0.390 → 39%.
  5. Hue when green is the max: H = 60 × ((B − R) ÷ d + 2) = 60 × (0.536 + 2) = 152°.

Result: hsl(152, 39%, 30%).

Common colors in HEX and HSL

ColorHEXHSL
Red#ff0000hsl(0, 100%, 50%)
Orange#ffa500hsl(39, 100%, 50%)
Yellow#ffff00hsl(60, 100%, 50%)
Green#008000hsl(120, 100%, 25%)
Dodger blue#1e90ffhsl(210, 100%, 56%)
Purple#800080hsl(300, 100%, 25%)
Gray#808080hsl(0, 0%, 50%)
White#ffffffhsl(0, 0%, 100%)

Working with HSL in CSS

  • Shades and tints: keep hue and saturation, change only lightness. Lower L by 5–10% for hover and active states.
  • Muted versions: lower saturation to make a color calmer without changing its hue.
  • Color themes: store hue, saturation and lightness as CSS custom properties and combine them with calc(), as in the snippet above.
  • Transparency: add an alpha value, hsl(152 39% 30% / 0.5), instead of creating a separate color.

Frequently asked questions

How do I convert HEX to HSL?

Split the HEX code into red, green and blue (00–FF each) and divide by 255. Lightness is (max + min) ÷ 2, saturation is (max − min) ÷ (1 − |2L − 1|), and hue depends on which channel is largest. For #2f6b4f this gives hsl(152, 39%, 30%).

What does HSL stand for?

Hue, saturation and lightness. Hue is the position on the color wheel from 0 to 360 degrees (0 red, 120 green, 240 blue), saturation is the color intensity from 0% (gray) to 100%, and lightness runs from 0% (black) through 50% (pure color) to 100% (white).

Why doesn't HSL convert back to exactly the same HEX?

HSL values are usually rounded to whole numbers, which can shift a channel by one step when converting back. The exact HSL row shows decimal values that round-trip precisely.

Can I use HSL in CSS?

Yes. All modern browsers support hsl(152, 39%, 30%) and the newer space-separated form hsl(152 39% 30%), including an alpha value like hsl(152 39% 30% / 0.5).

Why use HSL instead of HEX?

HSL is easier to adjust by hand: you can make a color lighter, darker or more muted by changing one number, and build consistent shades for buttons, hovers and themes from a single hue.

What is an 8-digit HEX color?

The last two digits are the alpha (opacity) from 00 (transparent) to FF (opaque). #2f6b4f80 is the same green at about 50% opacity, equal to hsla(152, 39%, 30%, 0.5).

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

RGB to HEXConvert RGB to HEX with sliders, live swatch and one-click copy.HEX to RGBConvert HEX colors to RGB and other formats.Color Palette GeneratorGenerate beautiful color palettes and export them.Color Name FinderFind the closest color name for any HEX or RGB color.Color Shades GeneratorTurn one HEX color into a 50-950 scale plus tints, shades and tones, ready to export.Color WheelFind complementary, triadic, analogous and other color harmonies on an interactive wheel.Tailwind Color GeneratorTurn one color into a full Tailwind 50–950 shade scale and export the config or CSS.RGB to CMYK ConverterConvert RGB and HEX colors to CMYK for print, and back.Color Contrast CheckerCheck WCAG contrast ratios and find accessible text colors.Pantone to HEXLook up approximate HEX, RGB and CMYK values for Pantone colors.Color Blindness SimulatorSee any image as people with protanopia, deuteranopia, tritanopia or achromatopsia see itImage Color PickerPick any pixel colour from an image and get HEX, RGB, HSL plus a paletteColor MixerMix two colors in sRGB, linear, OKLab or OKLCH, or blend them with Photoshop-style modes.Random Color GeneratorGenerate random HEX colors one at a time or in batches, with hue, saturation and lightness ranges.Color PickerPick any color and get HEX, RGB, HSL, HSV and CMYK codes, shades and a screen eyedropper.HTML Color CodesAll 140 HTML color names with HEX and RGB codes, plus the 216 web-safe colors. Click to copy.Color Palette from ImageExtract the main colors of any photo as HEX codes, CSS variables and a palette PNG.Replace Color in ImageClick a color in a picture and swap it for a new color or transparency, keeping the shading.CMYK to RGBConvert CMYK percentages to RGB and HEX color codes with sliders and a live preview.HSL to HEXConvert HSL and HSLA colors to HEX and RGB with sliders and a live preview.HEX to RGBAConvert HEX color codes to CSS rgba() with an opacity slider and one-click copy.RGBA to HEXConvert rgba() colors to 8-digit HEX, or flatten transparency onto any background.HEX to CMYKConvert HEX color codes to CMYK percentages for print, with a live preview.HEX to PantoneFind the 5 closest Pantone-style solid coated colors for any HEX or RGB, ranked by Delta E.Color Temperature to RGBConvert a color temperature in kelvin (1000-40000 K) to RGB and HEX with a live swatch.OKLCH Color ConverterConvert HEX, RGB and HSL to OKLCH, OKLab, Lab and LCH with sRGB and P3 gamut checks.RAL to HEXLook up RAL Classic codes as HEX, RGB and CMYK, search by name or find the nearest RAL.RGB to HSLConvert RGB values to HSL, HSV and HWB with a live swatch and copy-ready CSS.Color Code ConverterConvert a color between HEX, RGB, HSL, HSV, CMYK, LAB, LCH and OKLCH with a live swatch.Room Paint Color VisualizerUpload a room photo, select the walls and preview any paint color or HEX with real lighting.Photo to Pop ArtMake Warhol-style pop art from a photo: posterized color tiles in 1, 4 or 9 grids with custom palettes.Screen Color PickerPick any pixel color from anywhere on your screen and copy it as HEX, RGB or HSL.Solid Color Image GeneratorMake a plain single-color or transparent image in any size, like 1920x1080, as PNG or JPG.White Balance CorrectorFix color casts: click a neutral gray point or use auto gray world, then fine-tune temperature and tint.CMYK to HEXConvert CMYK percentages to a HEX color code and RGB, with a live swatch and shades.Photo Color MatchCopy the color grading of a reference photo onto your image (Reinhard color transfer).Underwater Photo Color CorrectionRestore lost reds and remove the blue or green cast from underwater photos by depth.
See all 38 Color Tools →