The RGB-to-HSV formula divides each 8-bit red, green, and blue channel by 255, sets V to the largest normalized channel, sets S to the range divided by V when V is greater than zero, and calculates H from the strongest channel across six 60-degree sectors.

After normalization, hue identifies a position around the color wheel, saturation describes the color’s distance from gray relative to its value, and value tracks the strongest RGB channel. HSV value is not the same measurement as HSL lightness or perceived luminance.

The calculations below show how to derive the result manually and how to verify the same coordinate transformation with a browser-based workflow.

convert rgb to hsv formula
Convert RGB to HSV Formula: Max, Delta, and Hue Math

The conversion formula at a glance

First normalize the input channels: R′ = R/255, G′ = G/255, and B′ = B/255. Next define M as the maximum of the three normalized channels, m as the minimum, and delta as M − m.

Component Calculation Output range Meaning
Hue, H Use the maximum-channel sector formula below At least 0° and below 360° Position around the color wheel
Saturation, S S = delta/M when M > 0; otherwise S = 0 0 to 1, commonly displayed as 0–100% Distance from the gray axis relative to value
Value, V V = M 0 to 1, commonly displayed as 0–100% Largest normalized RGB channel

The division in the saturation formula needs a special case. When M = 0, all channels are black, so V and S are both zero. When delta = 0 but M is greater than zero, all three channels are equal: saturation is zero, while hue has no visual meaning because the color is achromatic.

Build hue from six 60-degree sectors

When delta is not zero, calculate hue according to the channel with the largest normalized value:

  • If R′ is the maximum: H = 60 × (((G′ − B′)/delta) mod 6).
  • If G′ is the maximum: H = 60 × (((B′ − R′)/delta) + 2).
  • If B′ is the maximum: H = 60 × (((R′ − G′)/delta) + 4).
  • If delta = 0: use H = 0 as the achromatic placeholder.

Here, “mod” means the nonnegative remainder. Apply a final H = H mod 360 rule so a negative intermediate cannot produce an invalid hue angle. The three maximum-channel cases collectively cover six sectors: R-max spans 300°–60°, G-max spans 60°–180°, and B-max spans 180°–300°. When two channels tie for the maximum, use a deterministic priority order: R over G over B.

Work through one integer RGB conversion

Consider the 8-bit input R = 60, G = 120, and B = 180.

Normalize the channels: R′ = 60/255, G′ = 120/255, and B′ = 180/255.

Find the extrema: M = 180/255, m = 60/255, and delta = 120/255. Blue is the maximum channel.

Calculate value: V = M = 180/255, which is approximately 70.59% when displayed as a percentage.

Calculate saturation: S = delta/M = (120/255)/(180/255) = 2/3, which is approximately 66.67%.

Calculate hue: because blue is largest, H = 60 × (((R′ − G′)/delta) + 4) = 60 × ((60/255 − 120/255)/(120/255) + 4) = 60 × 3.5 = 210°.

Result: H = 210.00°, S = 66.67%, and V = 70.59% when rounded to two decimal places. The underlying calculation retains full floating-point precision until formatting.

Convert RGB channels in the browser

  1. Open the RGB to HSV Converter and enter whole-number red, green, and blue channel values from 0 through 255.
  2. Select Convert to HSV.
  3. Read hue in degrees and saturation and value as percentages. The result also includes normalized HSV notation, the source HEX code, and a visual swatch.
  4. Check whether the destination expects degrees and percentages, zero-to-one fractions, or a compact integer range before copying the values.

The input channels remain visible, making it possible to change one value and compare how the three HSV components respond. The converter performs the calculation locally in the browser and does not save a color history.

Match HSV output to the destination scale

A correct mathematical conversion can still produce a wrong result if the receiving application expects different units. Use the following distinctions when transferring the output:

Destination convention What the converter shows Transfer rule
Hue in degrees, with saturation and value as percentages H from 0 up to 360 degrees, plus S and V from 0–100% Use the displayed values directly when the destination follows this convention.
Hue in degrees, with saturation and value as zero-to-one fractions The same degree and percentage results Divide the displayed saturation and value percentages by 100. Follow the destination’s separate rule for hue if it does not use degrees.
A compact integer range such as 0–179 or 0–255 Degree-based hue and percentage-based S and V Do not copy the numbers directly. Apply the application’s documented scaling and confirm whether saturation and value are percentages, fractions, or integers.

Android’s Color documentation defines hue as at least zero and below 360, with saturation and value in the zero-to-one range. The converter’s implementation is independently checked against the R rgb2hsv convention for typical 0–255 sRGB input.

The interface displays two decimal places, but another program may round or format the same values differently. Confirm the destination’s accepted units and precision rather than assuming every HSV representation uses the same scale.

Edge cases and strict input rules

  • Black: M = 0, so V = 0 and S = 0. Hue is reported as the conventional 0-degree placeholder.
  • Equal red, green, and blue: delta = 0, so the color is achromatic and saturation is zero. Hue is visually undefined, so the converter uses 0 degrees.
  • Invalid RGB entries: only finite whole-number channels from 0 through 255 are accepted. Decimal values, empty fields, negative numbers, and values above 255 produce an explicit error instead of being silently rounded or clamped.
  • HSV value versus HSL lightness: HSV value is the maximum normalized RGB channel. HSL lightness instead uses the average of the maximum and minimum channels, so the two numbers should not be relabeled.

Strict validation is useful for ordinary 8-bit RGB codes because it prevents a mistyped channel from becoming a plausible but different color. It also keeps the scope clear: the converter accepts integer RGB triplets, not arbitrary decimals or values from a wider color system.

Know what the conversion does not establish

This is a defined coordinate transformation of an 8-bit sRGB-style triplet. It is useful for CSS exploration, graphics scripting, teaching, comparing palette coordinates, and moving a color sample into an HSV-based control. It does not read embedded image profiles, convert between wide-gamut color spaces, or report a subjective color name or design recommendation.

Alpha is outside the conversion because transparency does not change the HSV calculation for the underlying red, green, and blue channels. If the destination expects HSL, use an HSL converter rather than treating HSV value as HSL lightness.

Conversion also does not establish whether a foreground and background pair is readable. For interface work, test the actual color pair with the Color Contrast Checker instead of assuming that a successful HSV conversion guarantees accessible contrast.

For a deeper look, see How Do I Decide Whether I Need to Convert CMYK to RGB?.

For a deeper look, see Before Mixing Two HEX Colors: Format, Ratio, and Math.