Glossary

HSV

HSV is a color model that describes a color by hue, saturation and value, where value is the largest of the red, green and blue channels. HSV stands for Hue, Saturation, Value, and some software calls the same model HSB, for brightness. It was described by Alvy Ray Smith in 1978, and it is the model behind the square-plus-slider layout of many color pickers. CSS has no hsv() function, so you convert HSV to RGB, hex or hsl() before using it in a stylesheet.

How it works

HSV tilts the RGB cube onto its black corner and measures positions around that diagonal. Smith called the resulting solid a hexcone, a hexagonal pyramid with black at the tip.

  • Hue: the angle around the wheel, 0 to 360 degrees, with red at 0. It is computed exactly as in HSL, so the same color has the same hue in both models.
  • Saturation: the distance from gray as a share of the maximum possible for that value. 0 is a gray and 100% is the most vivid version of the hue.
  • Value: the largest channel divided by 255. 0 is black. 100% is the brightest the color can be.

The key difference from HSL is how white is reached. In HSV, white needs saturation 0 and value 100%. Pure blue is saturation 100% and value 100%. In HSL, pure blue sits at lightness 50% and white needs lightness 100%.

Python ships HSV in its standard library as colorsys, with every component scaled to 0 to 1.

import colorsys
r, g, b = 59 / 255, 130 / 255, 246 / 255
h, s, v = colorsys.rgb_to_hsv(r, g, b)
print('hsv', round(h * 360, 1), round(s * 100, 1), round(v * 100, 1))
h, l, s = colorsys.rgb_to_hls(r, g, b)
print('hls', round(h * 360, 1), round(l * 100, 1), round(s * 100, 1))
print([round(x * 255) for x in colorsys.hsv_to_rgb(240 / 360, 1, 1)])
print([round(x * 255) for x in colorsys.hsv_to_rgb(240 / 360, 1, 0.5)])
print([round(x * 255) for x in colorsys.hsv_to_rgb(0, 0, 1)])
hsv 217.2 76.0 96.5
hls 217.2 59.8 91.2
[0, 0, 255]
[0, 0, 128]
[255, 255, 255]

The same color, #3b82f6, has hue 217.2 in both models. Its HSV saturation is 76.0% and its value is 96.5%, while HSL gives it saturation 91.2% and lightness 59.8%.

What is the difference between HSV and HSL?

HSV and HSL share the same hue but differ in their other two axes. HSV value is the largest RGB channel, while HSL lightness is the average of the largest and smallest channel. The two saturation numbers therefore differ for the same color, as the run above shows (76.0% against 91.2%).

Common pitfalls

  • Copying saturation between HSV and HSL: the two percentages mean different things. A value like 76% saturation from a design tool in HSV is not 76% in hsl(). Convert through RGB.
  • Wrong tuple order in Python: colorsys.rgb_to_hsv returns (h, s, v) but colorsys.rgb_to_hls returns (h, l, s). Swapping the last two silently gives a wrong color.
  • Hue as a 0 to 1 fraction: colorsys uses 0 to 1 for hue. Multiply by 360 for degrees, and divide by 360 on the way back.
  • Different scales in different tools: the model is the same, but one application may show hue 0 to 360 and saturation 0 to 100, while another uses 0 to 255 or 0 to 240. Check the range before copying numbers.
  • Treating hue as meaningful at saturation 0 or value 0: the output is gray or black, so any hue you read back is arbitrary.

Related terms

  • RGB — the channels HSV is computed from
  • HSL — the sibling model with a lightness axis instead of value
  • Hex color — the compact notation you usually end up with after converting
  • sRGB — the color space the RGB inputs are normally in
  • CMYK — the subtractive print model, unrelated to hue angles

See also

  • Tool: Color Converter — Convert colors between HEX, RGB, HSL, HSV, and CMYK.
  • Tool: Color Picker — Pick any color with a visual spectrum, enter values in HEX, RGB, HSL, or CMYK, and copy.
  • Cheatsheet: Color Formats Cheatsheet — CSS color syntax side by side