HEX RGB HSL Color Converter
This is a one-direction converter with a contrast check attached. Start from a three- or six-digit HEX code or the color picker and it fills the RGB and HSL values, writes three color: declarations you can paste into CSS, and then treats your color as text on a background you choose. HSL is printed to one decimal so that it resolves back to exactly the same color. The contrast panel shows the ratio and four pass or fail cells for WCAG AA and AAA, normal and large text.
How to convert and check contrast
- Pick a color with Pick a Color or type a three- or six-digit code into the HEX box. A leading # is optional. Anything else, including HEX with an alpha channel, is marked as invalid and the outputs are cleared.
- Read the read-only RGB and HSL fields. They update as soon as the HEX is valid.
- Under CSS Code, press Copy HEX, Copy RGB or Copy HSL to copy a full
color: ...;declaration. - In the contrast panel, choose a Background Color. The sample box, the ratio and the four AA and AAA cells update. Your HEX color is the text color.
- To test the reverse pairing, type the old background color into the HEX box. The background itself can only be changed with its picker.
How the contrast ratio is calculated
WCAG defines contrast as (L1 + 0.05) / (L2 + 0.05), where L is relative luminance and L1 is the lighter color. Luminance is computed after converting each sRGB channel to linear light and weighting green most heavily (0.7152), then red (0.2126), then blue (0.0722). WCAG does not round the ratio up, so this tool cuts it to two decimals instead of rounding: #008580 on white is 4.49995:1, which is shown as 4.49:1 beside its AA fail, never as 4.50:1.
A ratio of 4.5:1 passes AA for body text and AAA for large text, 3:1 passes only AA large, and body text needs 7:1 for AAA. WCAG calls text large at 18pt (24 CSS pixels), or 14pt (about 18.7 pixels) when bold. The sample box sets one line at 24 pixels and one at 16 pixels in your two colors, so you can judge the pair by eye, which helps because a passing ratio on thin type can still feel weak.
The check covers solid text on a solid background only, so judge the result in context. It does not account for transparency, gradients or images behind text, and it does not test non-text contrast such as borders or icons, which has its own 3:1 requirement. Run the real page through a browser audit for those cases.