How HEX to HSV conversion works
HSV (called HSB in Adobe and Apple software) describes a colour the way most colour-picker squares are laid out: hue around the ring, saturation left to right, value (brightness) bottom to top. From HEX, value is simply the brightest channel, and saturation is how much the dimmest channel falls short of it.
- Decode the HEX pairs to R, G, B and divide by 255.
- Cmax = max(R′, G′, B′), Cmin = min(R′, G′, B′), Δ = Cmax − Cmin.
- V = Cmax.
- S = 0 if Cmax = 0, otherwise Δ ÷ Cmax.
- H is the same as for HSL: 60° × ((G′ − B′) ÷ Δ mod 6), ((B′ − R′) ÷ Δ + 2) or ((R′ − G′) ÷ Δ + 4) depending on which channel is largest.
- Round:
hsv(H, S%, V%).
Worked example: #FA5252 to HSV
Here is the converter's own calculation for #FA5252, step by step. The result, hsv(0, 67%, 98%), is exactly what the tool above shows for this input.
- Split into pairs: FA, 52, 52.
- Red: FA = 15 × 16 + 10 = 250.
- Green: 52 = 5 × 16 + 2 = 82.
- Blue: 52 = 5 × 16 + 2 = 82.
- R′ = 250 ÷ 255 = 0.98, G′ = 0.322, B′ = 0.322.
- Cmax = 0.98, Cmin = 0.322, Δ = 0.659.
- V = Cmax = 0.98.
- S = Δ ÷ V = 0.672.
- Red is largest: H = 60° × ((0.322 − 0.322) ÷ 0.659 mod 6) = 0°.
- Rounded:
hsv(0, 67%, 98%).
Open Color, index 6 in HEX and HSV
The thirteen index-6 colours from Open Color, an open-source palette tuned for UI.
| Colour | HEX | HSV |
|---|---|---|
| gray | #868E96 | hsv(210, 11%, 59%) |
| red | #FA5252 | hsv(0, 67%, 98%) |
| pink | #E64980 | hsv(339, 68%, 90%) |
| grape | #BE4BDB | hsv(288, 66%, 86%) |
| violet | #7950F2 | hsv(255, 67%, 95%) |
| indigo | #4C6EF5 | hsv(228, 69%, 96%) |
| blue | #228BE6 | hsv(208, 85%, 90%) |
| cyan | #15AABF | hsv(187, 89%, 75%) |
| teal | #12B886 | hsv(162, 90%, 72%) |
| green | #40C057 | hsv(131, 67%, 75%) |
| lime | #82C91E | hsv(85, 85%, 79%) |
| yellow | #FAB005 | hsv(42, 98%, 98%) |
| orange | #FD7E14 | hsv(27, 92%, 99%) |
Source: Open Color 1.9.1
Precision test: every HEX value through the converter
Whole-number HSV keeps slightly more of HEX than HSL does. Over all 16,777,216 codes the converter produced 2,475,339 distinct HSV values and 12.188% of codes survived the round trip exactly, with a worst drift of 3 levels (#0073FB came back as #0070FA) and an average of 0.9896.
Method: every whole-number HEX value, through the converter's own code and back, compared on the 0–255 scale (how we test).
| Measure | Result |
|---|---|
| HEX values tested | 16,777,216 |
| Distinct HSV results | 2,475,339 |
| Came back exactly | 12.188% |
| Largest change (0–255 levels) | 3 |
| Average change | 0.9896 |
Last updated · Source: Pixohub exhaustive test of lib/color-math.ts
Where you'll use HEX to HSV
Typing a brand colour into Photoshop or Figma's HSB fields
Photoshop's Color Picker shows H, S and B next to the # field, and Figma's picker can switch to HSB. Converting first tells you where the colour sits on the picker square, useful when you want a lighter variant that stays on the same hue.
Mobile and game code
Android's Color.colorToHSV(), iOS's UIColor(hue:saturation:brightness:alpha:) and Unity's Color.RGBToHSV() all work in HSV/HSB with values from 0 to 1, so divide the percentages on this page by 100.
Generating palettes programmatically
Rotating hue while keeping S and V fixed gives evenly bright colours for charts. The Open Color index-6 colours below are a good example: their V stays high while hue walks around the wheel.
Common mistakes
- Writing
hsv()in CSS: browsers don't support it. Convert to HEX,rgb(),hsl()orhwb()for stylesheets. - Assuming S means the same in HSV and HSL: pure white has S = 0 in both, but a pale pink can be 30% in HSV and 100% in HSL.
- Forgetting the 0–1 scale in code APIs:
Color.HSVToColor()on Android takes hue in degrees but saturation and value from 0 to 1. - Expecting V = 100% to mean white: it means the brightest channel is at full strength; white also needs S = 0%.