By Tim King · Updated
Luminance Scorer: Batch Contrast Checker
Batch WCAG Contrast Ratios for Hex Pairs, Exported as a Table or CSV
OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.
How the Luminance Scorer works
This batch contrast checker tests many colour pairs at once. Paste one foreground and background hex pair per line, separated by a space or a comma, and every pair comes back with its relative luminance values, its contrast ratio and a pass or fail against WCAG AA and AAA. Export the table as CSV for an audit.
Batch contrast checker: checking a palette at once
Checking one colour pair is easy. Checking the forty pairings a design system actually uses, with every text colour on every surface in both themes, is where a one-pair-at-a-time checker stops being useful. Paste the whole list here, one pair per line, and every row is scored at once against WCAG, with the luminance of each colour alongside.
Why it matters. Low contrast is the most common accessibility failure on the web. WebAIM's annual Million report, which audits the home pages of the top million sites, has found low contrast text on roughly four in five pages every year it has run. Around one in twelve men and one in two hundred women have some form of colour vision deficiency, and far more people read on a phone in sunlight or on a dim laptop. Contrast is also a legal matter: WCAG 2.1 and 2.2 level AA underpin the European Accessibility Act, the UK public sector regulations and most ADA settlements in the US.
How the luminance scorer works
Relative luminance is the perceived brightness of a colour, from 0 for black to 1 for white. Each sRGB channel is divided by 255, put through a curve that undoes display gamma, and weighted: 0.2126 red, 0.7152 green and 0.0722 blue. Those weights are why pure green has a luminance of 0.72 and pure blue only 0.07, even though both are one channel at full strength.
The contrast ratio formula is (lighter + 0.05) ÷ (darker + 0.05). It runs from 1:1 for identical colours to 21:1 for black on white. The 0.05 approximates light reflecting off the screen, and it is why the formula flattens small differences between very dark colours.
The thresholds follow WCAG 2.2:
- Body text: 4.5:1 for AA and 7:1 for AAA.
- Large text, meaning 24 px regular or about 18.66 px bold and above: 3:1 for AA and 4.5:1 for AAA.
- Interface components and meaningful graphics, such as input borders, focus rings, icons and chart lines: 3:1. Score these with the large-text setting.
Input format. Put the foreground first and the background second, separated by a space,
comma, semicolon or pipe. The # is optional and three-digit shorthand such as #333 works, so
you can paste straight from a spreadsheet, a CSV export or a design-token file.
Reading the results
Each row shows the two colours, the ratio, AA and AAA pass or fail, and both luminances.
- Pairs checked counts rows that contained two valid hex colours.
- Passing AA is how many of those meet the AA level for the text size you chose. It is the one figure to track over time.
- Threshold confirms which pair of targets was applied, so a screenshot of the results is self-explanatory.
- Skipped appears when lines had no usable hex pair, such as a header row, an
rgb()value or a named colour. Check it is the number you expect.
Worked example. Tailwind's gray-500 (#6b7280) on gray-100 (#f3f4f6) scores 4.39:1 and
fails AA for body text, even though the same grey on white passes. #767676 on white is the
lightest neutral grey that passes, at 4.54:1; one step lighter, #777777, scores 4.48:1 and
fails. Pure red on white is 4.00:1, fine for a large heading but not for an error message in
body text.
Tips and pitfalls.
- The rounding trap. Ratios are shown to two decimals, but pass or fail uses the exact value. A row showing 4.50:1 can still fail if the true figure is 4.497. WCAG does not allow rounding up.
- Check the pairs nobody designed. Batch checks surface combinations like secondary text on the alternate surface, a muted label inside a highlighted row, or a disabled style reused as a real label. Those are where failures live.
- Check both themes. Dark mode palettes often fail differently, because the 0.05 constant compresses differences at the dark end.
- Sort a palette by luminance. Six "distinct" colours that all sit between 0.18 and 0.24 will look flat together whichever pairs you pick, and no pairwise check will tell you that.
- Transparency is not scored. Semi-transparent text changes with whatever sits behind it. Flatten it to the solid colour it renders as, then paste that.
- Automate once the palette settles. The same formula runs in a linter or CI check against your design tokens, so contrast cannot quietly regress.
For a single pair with a live preview, use the contrast checker. To build a palette that has room for contrast from the start, try the colour harmonizer, and read colour contrast that passes WCAG for fixes that keep the brand look.
FAQ
What format should the input be in?
One pair per line, foreground first, separated by a space, comma, semicolon or pipe. Three-digit and
six-digit hex are both accepted, with or without the leading #. Lines that are not a valid pair are
reported in the table rather than silently dropped.
What is relative luminance?
The brightness of a colour as the eye perceives it, from 0 for black to 1 for white. It is calculated by linearising each sRGB channel and weighting them 0.2126 red, 0.7152 green and 0.0722 blue, reflecting how much each contributes to perceived brightness.
What ratio do I need to pass?
4.5:1 for body text and 3:1 for large text at WCAG AA, or 7:1 and 4.5:1 at AAA. Switch the text size option at the top and the pass and fail columns re-grade against the appropriate thresholds.
Does this cover interface elements as well as text?
Non-text elements that convey meaning — input borders, focus indicators, icons, chart series — need 3:1 against their surroundings. Select large text mode and read the AA column, which uses that same 3:1 threshold.
Can I export the results?
Yes. The table has a CSV download button, so the whole audit drops straight into a spreadsheet or an accessibility report. Nothing is uploaded — the calculation and the export both happen in your browser.
See also: all Colour tools, Layout & Spacing, Shadows & Motion, Shapes & SVG, UI Components, Forms & Inputs.
Related tools
Contrast Checker
Check colour contrast against WCAG and APCA.
Analogous Colour Generator
Generate neighbouring hues from one colour with tints and CSS.
Colour Palette Generator
Generate a full UI palette with light and dark modes from one colour.
Colour Picker
Pick a colour and copy it in every CSS format at once.
Complementary Colour Generator
Find a colour's complement with tints, shades and copyable CSS.