Formulas and sources
Each formula this calculator uses, where it comes from, and what it leaves out. "How it works" shows the same formula with your own numbers.
HEX and RGB
Every mode
Each pair of hex digits in #RRGGBB is a base-16 number from 00 to FF, which is 0 to 255 for red, green and blue. A three-digit code such as #FB0 is read as #FFBB00. HEX and RGB write the same sRGB color two ways, so they convert exactly. Codes with an alpha pair (4 or 8 digits) and color names are not accepted.
Source: Uses the notation in CSS Color Module Level 3, a W3C Recommendation [1], which specifies every RGB color in the sRGB color space of IEC 61966-2-1 [4].
RGB to HSL
Every mode
- R
- red, as 0 to 1 (0 to 255 divided by 255)
- G
- green, as 0 to 1
- B
- blue, as 0 to 1
- H
- hue, in degrees; 360° is added to a negative hue
- S
- saturation, shown as a percentage
- L
- lightness, shown as a percentage
- d
- max - min, the spread of R, G and B
max and min are the largest and smallest of R, G and B; min(L, 1 - L) is the smaller of L and 1 - L. A gray (d = 0) shows H and S as 0. H, S and L are rounded to whole numbers, and a hue can round to 360°, the same color as 0°.
Source: Uses the RGB-to-HSL conversion in CSS Color Module Level 4 [2], a Candidate Recommendation Draft, rounded to whole numbers. HSL typed in Advanced mode goes back to RGB by the conversion in CSS Color Module Level 3 [1].
RGB to CMYK
Every mode
- R
- red, as 0 to 1
- G
- green, as 0 to 1
- B
- blue, as 0 to 1
- C
- cyan
- M
- magenta
- Y
- yellow
- K
- black (key)
Each is shown as a whole percentage, and black (K = 1) shows C, M and Y as 0. It does not know the inks, the paper or a printer's profile, so a printed color can look quite different from the screen.
Source: Uses the naive conversion in CSS Color Module Level 5 [3], a Working Draft, which calls it necessarily approximate. Its own pair, rgb(178 34 34) and cmyk 0%, 81%, 81%, 30%, matches here.
Sources
- World Wide Web Consortium (W3C). CSS Color Module Level 3, sections 4.2.1, RGB color values, and 4.2.4, HSL color values. W3C Recommendation, January 18, 2022.
- World Wide Web Consortium (W3C). CSS Color Module Level 4, section 7.2, Converting sRGB Colors to HSL. Candidate Recommendation Draft, September 30, 2026; a draft that may change.
- World Wide Web Consortium (W3C). CSS Color Module Level 5, section 6.1, Naively Converting Between Uncalibrated CMYK and sRGB-Based Color. Working Draft, September 13, 2026; a draft that may change.
- International Electrotechnical Commission (IEC). IEC 61966-2-1:1999, Multimedia systems and equipment, Colour measurement and management, Part 2-1: Colour management, Default RGB colour space, sRGB. Edition 1.0, October 18, 1999.
What this calculator does not cover
- It converts one sRGB color between HEX, RGB, HSL and CMYK. The CMYK value is a simple formula, not a printer's profile.
- It does not take color names, alpha, HWB or wide-gamut colors such as Display P3.
- It does not check color contrast or build palettes. For layout dimensions and image sizing, see the Aspect Ratio Calculator.
Sources checked on .