Relative Luminance Calculator

Calculate the relative luminance of any color (0 = absolute black, 1 = absolute white) using the WCAG 2.x linearization formula, essential for contrast ratio and accessibility compliance checks.

Relative luminance

0.1831

Color: #1A73E8 β€” rgb(26, 115, 232)

Linearized channels

R_linear0.01033
G_linear0.17144
B_linear0.80695

WCAG contrast ratios

vs white4.51:1AA
vs black4.66:1AA

Luminance breakdown

Red contribution (0.2126 Γ— red_linear)0.00220
Green contribution (0.7152 Γ— green_linear)0.12261
Blue contribution (0.0722 Γ— blue_linear)0.05826

Quick answer

Relative luminance is a perceptual measure of a color's brightness, ranging from 0 (pure black) to 1 (pure white), as defined by WCAG 2.x and the IEC 61966-2-1 sRGB standard. To calculate it, each 8-bit RGB channel is divided by 255, gamma-corrected to linear light, and then combined using the weighted sum L = 0.2126R + 0.7152G + 0.0722B. The weights reflect human eye sensitivity: green contributes most to perceived brightness, red contributes moderately, and blue contributes least. Relative luminance is the foundation for computing the WCAG contrast ratio between two colors, which must be at least 4.5:1 for normal text (AA) and 7:1 for enhanced (AAA) compliance.

Formula & method

C_sRGB = C_8bit / 255
  • C_8bit β€” Raw channel value (0–255)
  • C_sRGB β€” Normalized channel value (0–1)

Step 1: Normalize each 8-bit channel (0–255) to a 0–1 floating-point value.

C_linear = C_sRGB / 12.92  if C_sRGB ≀ 0.04045,  else  ((C_sRGB + 0.055) / 1.055)^2.4
  • C_sRGB β€” Normalized channel value (0–1)
  • C_linear β€” Linearized channel value (0–1), representing physical light intensity

Step 2: Apply the sRGB gamma linearization (inverse gamma) to each normalized channel.

L = 0.2126 Γ— R_linear + 0.7152 Γ— G_linear + 0.0722 Γ— B_linear
  • L β€” Relative luminance (0 = black, 1 = white)
  • R_linear β€” Linearized red channel
  • G_linear β€” Linearized green channel
  • B_linear β€” Linearized blue channel

Step 3: Compute relative luminance using ITU-R BT.709 luma coefficients. These weights reflect human eye cone sensitivity.

Examples

Example 1: Pure White #FFFFFF
Input
R=255, G=255, B=255
Result
Relative luminance = 1.0000
Why
Each channel normalizes to 1.0. After linearization (1.0 > 0.04045): ((1.0 + 0.055) / 1.055)^2.4 = 1.0. L = 0.2126Γ—1.0 + 0.7152Γ—1.0 + 0.0722Γ—1.0 = 1.0000. Pure white has the maximum luminance of 1.
Example 2: Pure Black #000000
Input
R=0, G=0, B=0
Result
Relative luminance = 0.0000
Why
Each channel normalizes to 0.0. Since 0 ≀ 0.04045, linearization gives 0 / 12.92 = 0 for all channels. L = 0.2126Γ—0 + 0.7152Γ—0 + 0.0722Γ—0 = 0.0000. Pure black has the minimum luminance of 0.
Example 3: Pure Red #FF0000
Input
R=255, G=0, B=0
Result
Relative luminance = 0.2126
Why
R normalizes to 1.0, linearizes to 1.0. G and B normalize and linearize to 0. L = 0.2126Γ—1.0 + 0.7152Γ—0 + 0.0722Γ—0 = 0.2126. Red's luminance exactly equals the red coefficient, demonstrating that green dominates perceived brightness.
Example 4: Medium Gray #808080
Input
R=128, G=128, B=128
Result
Relative luminance β‰ˆ 0.2160
Why
Each channel: 128/255 = 0.5020. Since 0.5020 > 0.04045: ((0.5020+0.055)/1.055)^2.4 = (0.5280)^2.4 β‰ˆ 0.2160. L = (0.2126+0.7152+0.0722)Γ—0.2160 = 1.0Γ—0.2160 β‰ˆ 0.2160. Note that #808080 is not perceptually 50% gray in luminance terms due to gamma encoding.

Frequently asked questions

What is relative luminance and why does it matter for accessibility?

Relative luminance is a WCAG-defined measure of a color's perceived brightness on a scale of 0 (black) to 1 (white). It matters because WCAG contrast ratios β€” required for accessible text β€” are computed directly from the luminance values of the foreground and background colors. Without correct luminance values, you cannot verify AA (4.5:1) or AAA (7:1) compliance.

How is relative luminance different from lightness (HSL)?

HSL lightness is a simple average-based approximation that does not account for human eye sensitivity to different wavelengths. Relative luminance uses ITU-R BT.709 coefficients (0.2126 R, 0.7152 G, 0.0722 B) that reflect how much each color channel contributes to perceived brightness. #FF0000 (red) has an HSL lightness of 50% but a relative luminance of only 0.2126.

What does the gamma linearization step do?

Digital images use gamma encoding (sRGB) so that more bit values are allocated to dark shades where human perception is most sensitive. Before computing luminance, you must undo this encoding (linearize) so that the values represent actual light intensity. Values ≀ 0.04045 are in a near-linear region and use simple division; higher values use the power function with exponent 2.4.

How do I calculate the WCAG contrast ratio using luminance?

Once you have the relative luminance of both colors, the contrast ratio is (L1 + 0.05) / (L2 + 0.05), where L1 is the lighter luminance and L2 is the darker. Adding 0.05 accounts for ambient light in a typical screen environment. For example, white (L=1.0) against black (L=0.0) gives (1.05) / (0.05) = 21:1, the maximum possible ratio.

Can I input a hex color code instead of separate RGB values?

Yes. A hex code like #1A2B3C maps directly to RGB: R=0x1A=26, G=0x2B=43, B=0x3C=60. You can split any 6-digit hex into three 2-digit hex pairs and convert each to decimal. This calculator accepts a hex field and converts it automatically, or you can enter the R, G, B values directly.

Why does green contribute so much more than blue to luminance?

The human eye has three types of cone cells. The L-cones (long wavelength, sensitive to red) and M-cones (medium, sensitive to green) are far more numerous and sensitive than S-cones (short, sensitive to blue). The BT.709 coefficients β€” 0.2126 R, 0.7152 G, 0.0722 B β€” encode this physiological reality. Blue contributes only about 7% of perceived brightness even at full intensity.

Sources & references

External references open in a new tab. We are independent and not affiliated with these organizations.

  • βœ“ Free to use
  • βœ“ No sign-up required
  • βœ“ Runs entirely in your browser β€” nothing is uploaded.
  • βœ“ Formula and method shown above

Provided β€œas is” for general information only β€” results may be inaccurate, so verify before you rely on them. No warranty; use at your own risk.

Built and reviewed by HIFreeTools against the formula shown above and any authoritative references cited on this page. See our methodology and editorial standards.

Related tools

Embed this tool on your site

Free to embed, no sign-up. Paste this code where you want the relative luminance calculator to appear: