DevTools Logo

Contrast Grid Builder

Contrast Grid Builder

Audit every foreground × background combination from two color lists in one WCAG matrix.

Runs in your browser

Color lists

6 foregrounds × 6 backgrounds

One color per line or comma-separated: hex, rgb(), hsl() or common named colors.

Alpha values are composited over white before the luminance calculation.

Try a list

Contrast matrix

36 pairs · 42% AA

36 pairs · 15 pass AA · 8 pass AAA · best 21.00:1 · worst 1.00:1

FG \ BG#FFFFFF#F8FAFC#E2E8F0#1A2B3C#DC2626#2563EB
#000000
#FFFFFF
#1A2B3C
#595959
#E11D48
#2563EB

Thresholds: AA ≥ 4.5:1 (normal text), AA large ≥ 3:1, AAA ≥ 7:1. Equality passes.

Examples

Token scale audit

Input
6 foregrounds × 6 backgrounds from a design-system scale
Output
36 cells with a pass percentage, best and worst pair, and CSV export.

The summary makes a systemic problem (for example a light gray text token) obvious immediately.

Identical pair

Input
#000000 on #000000
Output
1.00:1 · Fail

The grid shows the honest result rather than skipping unhelpful combinations.

Mixed formats

Input
rgb(0,0,0), white, #ffffff on a background list with hsl() and rgba() values
Output
Duplicates removed; alpha colors composited over white; ratios computed uniformly.

Normalizing formats first keeps the comparison meaningful and the CSV readable.

About this tool

Contrast Grid Builder turns two color lists into a complete WCAG contrast matrix. Every text color is paired with every surface color, and each cell shows a live 'Aa' preview, the exact ratio and a badge for AAA, AA, AA-large or fail. It is the systems-scale counterpart to a single-pair contrast checker: a whole token scale can be audited in one paste.

Lists accept hex (3, 4, 6 and 8 digits), rgb(), hsl(), and a subset of CSS named colors. Alpha channels are composited over white before luminance is computed, which is stated in the interface. Duplicate colors are removed and unparseable lines are reported individually, so one bad token never hides the rest of the audit. Axes can be swapped and sorted by input order, luminance or hue.

Clicking a cell reveals the exact ratio to three decimals, both relative luminances, pass/fail at all three thresholds, and a copyable CSS snippet. The matrix can be exported as CSV with one row per pair. All computation is browser-local; no color list is uploaded or saved.

What this tool does not do

  • Only a subset of CSS named colors is included; hex, rgb() and hsl() cover the rest.
  • Alpha colors are composited over white, not over an arbitrary chosen backdrop.
  • APCA and non-text UI-component contrast are not implemented in this version.
  • Very large lists produce large tables; there is no virtualization, so hundreds of colors per axis are impractical.
  • Contrast is necessary but not sufficient for accessibility — font size, weight and semantics still matter.

How to use this tool

  1. Paste two lists

    Put text colors in Foregrounds and surface colors in Backgrounds; one per line or comma-separated.

  2. Handle parsing notes

    Read the alerts for skipped invalid lines and the note for deduplicated colors.

  3. Configure the matrix

    Choose all bands, strict AA or strict AAA, sort either axis by luminance or hue, or swap the axes.

  4. Inspect a pair

    Click any cell for the exact ratio, luminances, all verdicts and a copyable CSS snippet.

  5. Export the audit

    Copy or download the CSV report with one row for every foreground/background combination.

Use cases

Design system QA

Validate a text-token scale against a surface-token scale before shipping.

Brand review

See which brand accent colors are readable on light and dark backgrounds.

Audit artifacts

Export a CSV matrix for an accessibility report or pull request.

Theme migration

Compare old and new palettes by swapping axes and sorting by luminance.

WCAG thresholds

BandRequirement
AA · normal textContrast ratio ≥ 4.5:1.
AA · large textContrast ratio ≥ 3:1 (18pt or 14pt bold and above).
AAA · normal textContrast ratio ≥ 7:1.
FailBelow 3:1; not acceptable for text.
Alpha colorsComposited over white before relative luminance is computed.

Equality at a threshold is a pass: exactly 4.5:1 meets AA.

Common mistakes

Mistake:Assuming a passing large-text pair also passes normal text.

Fix:Check the AA and AAA columns separately; large text needs only 3:1 while normal text needs 4.5:1.

Mistake:Trusting color-only badges.

Fix:Every cell prints the ratio and verdict as text, so the grid remains readable without color perception.

Mistake:Forgetting alpha compositing assumptions.

Fix:The tool composites over white; use a flat color if your real background is dark.

Mistake:Reading the pass percentage as a WCAG certification.

Fix:It summarizes pairs in this matrix only; real pages also depend on font size, weight and context.

Mistake:Expecting every CSS color name.

Fix:A common-name subset is supported; unknown names are reported as row errors rather than guessed.

Frequently asked questions

What contrast ratio do I need for AA vs AAA?

WCAG AA needs 4.5:1 for normal text and 3:1 for large text (about 18pt, or 14pt bold). AAA needs 7:1 for normal text and 4.5:1 for large text. Equality counts as a pass; the grid prints all three verdicts when you click a cell.

Does large text need less contrast?

Yes — larger, heavier glyphs are easier to read, so the AA large-text threshold is 3:1 rather than 4.5:1. Use the AA Large band only for text that meets the size definition; body copy still needs 4.5:1.

How is the ratio calculated?

Each sRGB channel is linearized (c/12.92 below 0.04045, otherwise ((c+0.055)/1.055)^2.4), combined as 0.2126R+0.7152G+0.0722B, then the lighter and darker luminances are compared as (L1+0.05)/(L2+0.05).

Can I audit two full palettes at once?

That is the main use case. Paste one palette into Foregrounds and the other into Backgrounds to get an N×M matrix. Sort either axis by luminance or hue, or swap the axes to test the reverse pairing.

Can I export the grid?

Yes. The Copy CSV and Download CSV actions produce one row per combination with both hex values, ratio, verdict and pass/fail flags for AA, AA large and AAA. Cell details also offer a copyable CSS pair.

What happens to invalid or duplicate colors?

Invalid lines are listed as errors and excluded from the matrix while valid rows still convert. Exact duplicate colors are removed once with a note, keeping the grid compact and the labels unambiguous.

How are alpha colors handled?

Colors with alpha, including #RRGGBBAA and rgba(), are composited over white before relative luminance is calculated. If your real surface is dark, flatten the color against that surface first and paste the resulting opaque value.

References & standards