Colour converter

Converts a colour between HEX, RGB and HSL and copies any of them with one click. Names the closest CSS colour, and measures the contrast between text and background using the W3C formula to tell you whether it meets the WCAG 2.2 accessibility thresholds. Also generates a lightness scale.

Runs in your browser · nothing is uploaded

Any format works: #1e90ff, 1e90ff, rgb(30 144 255), hsl(210, 100%, 55.9%) or dodgerblue.

Other formats (click to copy)

Preview

Text on this colour looks like this

· Whichever of black or white gives the higher contrast.

Contrast check

Treats the colour above as text and the colour below as its background, then measures the difference in brightness against the WCAG 2.2 thresholds.

Contrast ratio

    Lightness scale (click to select)

    The same hue and saturation with only the lightness changed. Useful for keeping backgrounds, borders and accents in one family.

    Assumptions

    How it is calculated

    Examples

    TextBackgroundRatioVerdict
    #000000#ffffff21.00 : 1Passes everything — the maximum
    #767676#ffffff4.54 : 1Body AA passes, AAA fails
    #777777#ffffff4.48 : 1Body AA fails — one step of grey decides it
    #1e90ff#ffffff3.24 : 1Only large text and non-text elements pass

    Common mistakes

    FAQ

    Why measure contrast at all?

    Text with too little brightness difference from its background is hard to read, especially for people with low vision or colour vision deficiency, and for anyone using a screen in bright daylight. WCAG 2.2 asks for at least 4.5:1 for body text and 3:1 for large text, with the stricter AAA level asking for 7:1 and 4.5:1. Public sector sites in many countries are legally required to meet the AA level.

    How is the ratio calculated?

    The relative luminance of each colour is computed, then divided as (lighter + 0.05) ÷ (darker + 0.05). Relative luminance normalises each channel to 0–1, undoes the gamma encoding, and adds them with weights of 0.2126, 0.7152 and 0.0722. Green carries the largest weight because the eye perceives it as the brightest. Black against white gives the maximum of 21:1; a colour against itself gives the minimum of 1:1.

    What counts as large text?

    WCAG defines it as 18pt or larger, or 14pt or larger when bold. In CSS pixels that is roughly 24px, or 18.66px bold. Larger glyphs have thicker strokes and stay legible at lower contrast, which is why the threshold drops from 4.5:1 to 3:1.

    What is the difference between HEX, RGB and HSL?

    They are three ways of writing the same colour, so conversion between them is exact. HEX is compact and convenient in code. RGB shows the primary light values directly. HSL splits the colour into hue, saturation and lightness, which makes adjustments like "the same colour but darker" straightforward. The lightness scale on this page is produced by changing only the L in HSL.

    Does it handle transparency?

    The input color is composited over the selected opaque background before measuring contrast.

    How is the nearest name chosen?

    By measuring the distance in RGB values to each of the 148 named CSS colours and picking the closest, flagging an exact match when there is one. That distance is arithmetic rather than perceptual, so treat the name as a rough family label rather than an identification.

    Related tools