# HSL to HSV

The HSL and HSV are popular color models for web and graphics design. While they have many similarities, they differ in some aspects, especially regarding their hue representation.

**What is HSL?**

HSL stands for Hue, Saturation, and Lightness. It is a cylindrical-coordinate representation of colors in the RGB color model. In the HSL color model, hue represents the angle on the color wheel (ranging from 0 to 360 degrees), saturation represents the distance from the center of the color wheel (ranging from 0 to 100%), and lightness represents the brightness of the color (ranging from 0 to 100%).

**What is HSV?**

HSV stands for Hue, Saturation, and Value. It is another cylindrical-coordinate representation of colors in the RGB color model. In the HSV color model, the hue also represents the angle on the color wheel (ranging from 0 to 360 degrees), saturation represents the distance from the center of the color wheel (ranging from 0 to 100%), and the value represents the brightness of the color (ranging from 0 to 100%). The main difference between HSL and HSV is that HSV uses value instead of lightness to represent brightness.

**HSL to HSV Conversion Formula?**

**To convert HSL to HSV, you need to use the following formulas:**

V = L + S * min(L, 1 - L)

S = V == 0 ? 0 : 2 * (1 - L / V)

H' = H / 60

if (H' < 0) H' = 6 - (-H') % 6

X = V * (1 - abs(H' % 2 - 1))

(R, G, B) = (V, X + L - 0.5 * V, L - 0.5 * V + X)

Where H is the hue angle in degrees (0 to 360), S is the saturation (0 to 1), L is the lightness (0 to 1), and V is the value (0 to 1).

**How to Convert HSL to HSV in Photoshop?**

**In Photoshop, you can easily convert HSL to HSV by following these steps:**

- Open your Image in Photoshop.
- Go to Image> Mode > HSL Color.
- Go to Image> Mode > HSV Color.

**That's it! Your Image is now converted from HSL to HSV.**

**How to Convert HSL to HSV in Illustrator?**

**In Illustrator, you can convert HSL to HSV by following these steps:**

- Open your document in Illustrator.
- Select the object or text whose color you want to convert.
- Go to the Color panel and click the small arrow in the top right corner.
- Choose "HSV" from the drop-down menu.

**Your color is now converted from HSL to HSV.**

**How to Convert HSL to HSV in CSS?**

You can **convert HSL to HSV in CSS** using the color() function. The color() function takes four arguments: the color model (either rgb, hsl, or hwb), the color values, and the alpha value (optional).

To convert HSL to HSV using the color() function, you need to convert the HSL values to RGB first, then convert the RGB values to HSV. Here's the formula:

hsv(h, s, v) = rgb(r, g, b) / max(r, g, b)

where

r = R / 255

g = G / 255

b = B / 255

and

h = (60 * ((g - b) / (max(r, g, b) - min(r, g, b))) + 360) % 360

s = (max(r, g, b) - min(r, g, b)) / max(r, g, b)

v = max(r, g, b)

**Once you have the HSV values, you can use them in the color() function like this:**

color: hsv(h, s, v);

**How to Convert HSL to HSV in JavaScript?**

In JavaScript, you can convert HSL to HSV by using the same formula we used earlier:

v = l + s * Math.min(l, 1 - l);

s = v === 0 ? 0 : 2 * (1 - l / v);

h = h / 60;

if (h < 0) h = 6 - (-h % 6);

x = v * (1 - Math.abs(h % 2 - 1));

rgb = [v, x + l - 0.5 * v, l - 0.5 * v + x];

**Once you have the RGB values, you can convert them to HSV using this formula:**

hsv = rgbToHsv(rgb[0] * 255, rgb[1] * 255, rgb[2] * 255);

**Here's the complete JavaScript function:**

function hslToHsv(h, s, l) {

let v, x, rgb;

v = l + s * Math.min(l, 1 - l);

s = v === 0 ? 0 : 2 * (1 - l / v);

h = h / 60;

if (h < 0) h = 6 - (-h % 6);

x = v * (1 - Math.abs(h % 2 - 1));

rgb = [v, x + l - 0.5 * v, l - 0.5 * v + x];

return rgbToHsv(rgb[0] * 255, rgb[1] * 255, rgb[2] * 255);

}

function rgbToHsv(r, g, b) {

let max = Math.max(r, g, b), min = Math.min(r, g, b);

let h, s, v = max;

let d = max - min;

s = max === 0 ? 0 : d / max;

if (max === min) {

h = 0; // achromatic

} else {

switch (max) {

case r: h = (g - b) / d + (g < b ? 6 : 0); break;

case g: h = (b - r) / d + 2;

But if you don't want any above tools and want to do online tools, then check out our tool: