How HSV to RGB conversion works
HSV to RGB is the conversion behind almost every colour picker: as you drag the handle, the picker turns its hue, saturation and value position into red, green and blue light for the screen.
- Scale S and V to 0–1.
- C = V × S (chroma), m = V − C.
- X = C × (1 − |(H ÷ 60) mod 2 − 1|).
- Choose (R′, G′, B′) from the hue's 60° sector.
- R, G, B = round((value + m) × 255).
Worked example: hsv(200, 60%, 90%) to RGB
Here is the converter's own calculation for hsv(200, 60%, 90%), step by step. The result, rgb(92, 184, 230), is exactly what the tool above shows for this input.
- Chroma C = 0.9 × 0.6 = 0.54.
- X = 0.54 × (1 − |(200 ÷ 60) mod 2 − 1|) = 0.36.
- m = 0.9 − 0.54 = 0.36.
- 200° is in the 180–240° sector, so (R′, G′, B′) = (0, X, C) = (0, 0.36, 0.54).
- Add m and multiply by 255: R = 92, G = 184, B = 230.
- Written as
rgb(92, 184, 230).
A pastel ring in HSV and RGB
Saturation 60% and value 90% held fixed, hue every 30°.
| Colour | HSV | RGB |
|---|---|---|
| 0° | hsv(0, 60%, 90%) | rgb(230, 92, 92) |
| 30° | hsv(30, 60%, 90%) | rgb(230, 161, 92) |
| 60° | hsv(60, 60%, 90%) | rgb(230, 230, 92) |
| 90° | hsv(90, 60%, 90%) | rgb(161, 230, 92) |
| 120° | hsv(120, 60%, 90%) | rgb(92, 230, 92) |
| 150° | hsv(150, 60%, 90%) | rgb(92, 230, 161) |
| 180° | hsv(180, 60%, 90%) | rgb(92, 230, 230) |
| 210° | hsv(210, 60%, 90%) | rgb(92, 161, 230) |
| 240° | hsv(240, 60%, 90%) | rgb(92, 92, 230) |
| 270° | hsv(270, 60%, 90%) | rgb(161, 92, 230) |
| 300° | hsv(300, 60%, 90%) | rgb(230, 92, 230) |
| 330° | hsv(330, 60%, 90%) | rgb(230, 92, 161) |
Precision test: every HSV value through the converter
All 3,672,360 whole-number HSV values convert to RGB and back to the same colour (100%), reaching 2,193,881 distinct RGB colours.
Method: every whole-number HSV value, through the converter's own code and back, compared on the 0–255 scale (how we test).
| Measure | Result |
|---|---|
| HSV values tested | 3,672,360 |
| Distinct RGB results | 2,193,881 |
| Came back exactly | 100% |
| Largest change (0–255 levels) | 0 |
| Average change | 0 |
Last updated · Source: Pixohub exhaustive test of lib/color-math.ts
Where you'll use HSV to RGB
Building your own colour picker
The HSV square is easy to draw, but the output has to be RGB for the screen and for any API. This is the conversion each pixel of a picker uses.
Pastel and muted palettes
Fixing S at around 60% and V at 90% and walking the hue gives soft, evenly bright colours, as in the ring below.
Embedded LEDs
LED animations often fade hue in HSV for smooth rainbow effects, then convert to RGB per frame for the driver. FastLED, for example, has its own CHSV type and hsv2rgb functions.
Common mistakes
- Using hue in 0–1 (as many libraries do) with degree-based formulas.
- Passing S and V as 0–255 (FastLED and OpenCV style) into a formula that expects 0–1.
- Expecting equal V to look equally bright: yellow at V = 90% looks much lighter than blue at V = 90%.
- Truncating instead of rounding the final values, which biases colours darker.