This page reads a colour value and returns the same colour in hex, RGB and HSL, with two tint swatches and a WCAG contrast check against white and black. Type a value, use the colour field, or paste the hex you copied from a design file. The sample, the conversion table and the contrast badges update together.
It accepts hex with three, four, six or eight digits, rgb() and rgba() with commas, spaces or a slash, hsl() or hsla(), and the standard CSS colour names including rebeccapurple and transparent. Alpha is read from a four or eight digit hex, from rgba() or from a slash value. The result is calculated locally and is not stored.
Values it reads
Hex is the most predictable input. Three digits are expanded, so #2f6 becomes #22ff66. Six digits are read as red, green and blue. Four and eight digits carry an alpha pair, and the page keeps it: #2f6f5e80 stays at half opacity rather than being flattened to #2f6f5e. The alpha pair is converted on a 0 to 255 scale, so 80 becomes 0.5.
The RGB parser accepts numbers from 0 to 255 and percentages, with commas, whitespace or a slash before the alpha. Both the legacy rgba(47, 111, 94, 0.4) form and the modern rgb(47 111 94 / 40%) form work. The HSL parser accepts a hue in degrees and saturation and lightness as percentages, with or without commas. Values outside the valid range are clamped, so a saturation of 140% is treated as 100%, and a value it cannot parse produces a failure message instead of a guessed colour.
CSS names are looked up rather than rejected. rebeccapurple becomes #663399 and tomato becomes #ff6347. transparent is treated as black at zero alpha, which is what the keyword means in CSS. Names are case-insensitive, and the output is always the numeric equivalent.
How the contrast check works
The contrast ratio follows the WCAG 2 formula. Each sRGB channel is converted to linear light, the three channels are weighted by 0.2126, 0.7152 and 0.0722 to get relative luminance, and the ratio is (lighter + 0.05) / (darker + 0.05). The page calculates the ratio against pure white and pure black and shows both, rounded to two decimal places.
When the colour is translucent, it is composited over each background first. A half-opacity red over white is a pale pink, and the ratio shown is the ratio of that blended result, not of opaque red. This is the number a reader actually sees, and it is why the same hex can pass on black and fail on white. The relative-luminance row always describes the opaque colour and is labelled that way when alpha is present.
The badges use the better of the two ratios. Normal text passes AA at 4.5:1 and AAA at 7:1. Large text passes AA at 3:1 and AAA at 4.5:1. Large here means at least 18pt, or 14pt bold, which is roughly 24px or 18.66px bold. The badges do not know your font size, so a large-text pass is only relevant if the text really is that large.
A worked example
The hex #2f6f5e produced the values below. Its relative luminance is 0.128, which gives 5.91:1 against white and 3.56:1 against black.
| Input | HEX | HSL | White | Black |
|---|---|---|---|---|
#2f6f5e | #2f6f5e | hsl(164 41% 31%) | 5.91:1 | 3.56:1 |
hsl(166 41% 31%) | #2f6f60 | hsl(166 41% 31%) | 5.89:1 | 3.56:1 |
rebeccapurple | #663399 | hsl(270 50% 40%) | 8.41:1 | 2.5:1 |
#2f6f5e80 | #2f6f5e80 | hsl(164 41% 31%) | 2.17:1 | 1.64:1 |
The first row is the ordinary case: the hex round-trips, the HSL saturation is the expected 41%, and the colour passes AA for normal text on white. The second row shows that HSL input and HSL output now agree, because the saturation is normalised once rather than twice.
The named colour is the convenience case. Typing a name you know is faster than looking up its hex, and the page resolves it to #663399 before doing the same contrast maths. The last row is the transparency case: half-opacity green has only 2.17:1 on white once it is blended, so it fails both text levels even though the opaque hex passes. That difference is the reason alpha is included rather than ignored.
Alpha, swatches and copying
The alpha checkbox changes the primary value and the HEX row to eight digits. When the input already has an alpha pair, that pair is preserved; when the colour is opaque, the checkbox writes ff. The checkbox does not change the colour or the contrast figures, because those already account for the alpha in the input.
The two swatches mix the opaque colour with white and black at 20%. They are a quick way to see a lighter and darker step, not a full tint scale, and they do not inherit transparency. The copy button writes a short text report and a :root block with the hex value, the RGB channels as space-separated numbers, and the HSL value. A translucent colour also gets a --colour-alpha line so the custom property set is complete.
If you are choosing a palette rather than checking one colour, work in the other direction: decide the contrast pair first, then pick the colour. The gradient generator uses the same hex values, and the box shadow generator accepts a six-digit hex for the shadow colour.