RGBA to HEX Converter
Turn an RGBA colour into an 8-digit HEX code, or flatten the alpha away.
Compute WCAG relative luminance and see the maths behind it.
The value appears here
The Relative Luminance Calculator computes the number underneath every contrast ratio and shows each step of the formula — gamma expansion per channel, then the 0.2126 / 0.7152 / 0.0722 weighting that makes green carry most of a colour’s brightness.
Relative luminance is the number underneath every contrast ratio: how much light a colour emits, on a scale where black is 0 and white is 1. This tool computes it and shows each step, which is the part the specification text makes hard to follow.
The calculation has two halves. First each sRGB channel is undone from its gamma encoding — the curve that lets 8 bits carry a perceptually even range — using the piecewise formula the sRGB standard defines. Then the three linear channels are weighted and added: 0.2126 red, 0.7152 green, 0.0722 blue.
Those weights are the interesting part, and seeing them makes several colour puzzles obvious at once. Green carries nearly three-quarters of the perceived brightness of a colour and blue less than a thirteenth, which is why pure blue text is so hard to read on black, why yellow feels so bright, and why averaging the three channels is not a usable measure of anything.
Each channel before and after gamma expansion, with its weighted contribution to the total.
The physical value and the perceptual one, which differ by roughly a cube root and are constantly confused.
Seeing that blue contributes 7% explains why blue text on black is unreadable, in one line.
The ratios against black and white are derived in front of you, so the arithmetic can be checked.
Implements the sRGB linearisation properly, including the straight-line segment below the threshold.
Any notation. The channels are read as 0–255 sRGB.
A value from 0 for black to 1 for white, with the perceptual lightness beside it.
Each channel is shown before and after gamma expansion, with its weighted contribution.
The ratio against black and white is computed from the same value, so you can check the arithmetic.
No. Luminance is physical — light emitted. Lightness is perceptual, and roughly the cube root of luminance: a colour with 0.2 luminance looks about half as bright as white, not a fifth. Both are shown here.
They follow the sensitivity of human vision, which peaks in the green part of the spectrum. The figures come from the Rec. 709 primaries that sRGB inherited.
Gamma expansion uses a straight line for very dark values and a power curve above them, because a pure power curve has an infinite slope at zero and would make the darkest steps unrepresentable. The threshold is where the two meet.
No. A translucent colour has no luminance of its own until it is composited over something. Flatten it against its real background first — the Alpha Blend Calculator does exactly that.
What people who use the Relative Luminance Calculator think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the Relative Luminance Calculator. It takes half a minute and no account.
Write the first reviewTurn an RGBA colour into an 8-digit HEX code, or flatten the alpha away.
Convert HEX colour codes to RGB and HSL, and back again.
Build a moving gradient background with the keyframes included.
Turn one brand colour into a complete, usable UI palette.
See your palette as a real interface instead of swatches.
All 148 CSS colour names, searchable and sortable.
Work out the solid colour a translucent layer really produces.
Convert to and from HWB, the hue-whiteness-blackness notation.