Token contrast matrix
Paste a design tokens file and see how every text colour reads on every background, in light and in dark. Each pair is scored with WCAG 2.2 and with APCA, and the ones that fall short can be copied out as Markdown. Nothing leaves your browser.
Matrix#
10 colour tokens in light. 2 modes found, read from the groups light and dark.
8 of 24 pairs pass AA
AA for body text is 4.5:1. 16 pairs fall short in light.
Show
Translucent backgrounds sit on
Choose rows and columns6 rows, 4 columns
Names with text, fg, foreground, icon, border or on- are foreground and become rows. Names with bg, background, surface, canvas, card or fill are backgrounds and become columns. Anything else is both. Change any token here.
Each cell is the row's colour as text on the column's colour. Hover, focus or tap a cell for the detail and a fix. Click a swatch to edit a colour.
How do I use it?#
Paste or drop your file
Paste the JSON into the box, drop a .json file onto it, press Open a .json file, or load one of the examples. The grid updates as you type. The example loaded at first has a light and a dark theme.
Pick a mode
If the file has light and dark modes, choose one above the grid. The grid and the export follow the mode you choose.
Read the grid
Rows are text colours and columns are backgrounds. Each cell shows the pair as it looks, the WCAG ratio, the APCA Lc and a level. Hover, focus or tap a cell for the detail, or filter to the pairs that fall short. Arrow keys move between cells.
Fix, export or check
Press Suggest a fix on a failing pair to see the nearest colour that reaches 4.5:1, or click a swatch to edit a colour yourself, then copy the updated tokens. Copy the pairs under 4.5:1 as Markdown for an issue or a pull request, or press Check file in validator to check the file against the W3C format first.
How does it score a pair?#
WCAG 2.2. The relative luminance of each colour is worked out from its sRGB channels, as the definition in WCAG 2.2 sets out, and the ratio is (lighter + 0.05) / (darker + 0.05). Black on white is 21:1.
APCA. The algorithm is APCA-W3 version 0.0.98G-4g, with the constants from the reference implementation. Lc is positive for dark text on a light ground and negative for light text on a dark one; its size, not its sign, is the contrast. As a check, #888888 on white scores Lc 63.1 and white on #888888 scores Lc -68.5.
Before either runs, a translucent colour is blended in sRGB the way a browser does it and rounded to eight bits, so the number matches what is on screen. A colour that cannot be read is marked in its cells rather than left out, and Check file in validator shows what is wrong with the file.
Use the design tokens validator to check the file against the W3C format, and the converter to turn it into CSS, Tailwind, SCSS or TypeScript. Orvain UI tokens ship in this format.
Questions#
Is my tokens file uploaded anywhere?
No. The file is read and scored in your browser, so what you paste or drop never leaves the page.
What is the difference between WCAG and APCA?
WCAG 2.2 contrast is a ratio between the lightness of two colours, from 1:1 to 21:1, and it is the same whichever colour is the text. APCA, the Accessible Perceptual Contrast Algorithm, gives a signed score called Lc that depends on which colour is the text and which is the ground, because light text on a dark ground reads differently from dark text on a light one. WCAG 2.2 is the current Recommendation and the one accessibility rules point to. APCA is proposed for WCAG 3, which is still a draft, so treat Lc as a second opinion rather than a pass mark.
Which one should I rely on?
Use the WCAG level when you need to show that something conforms. Use APCA as a check on the cases where the ratio is known to mislead, most often light text on dark backgrounds and mid-tone colours. When the two disagree, the pair is worth a look by eye. This tool shows both and does not combine them into one score.
What do the levels mean?
AAA is 7:1 or more. AA is 4.5:1 or more, the level for body text. AA large is 3:1 or more, the level for large text and, under success criterion 1.4.11, for borders and icons that carry meaning. Fail is under 3:1. The ratio is compared as it is, not rounded up, so 4.499:1 does not pass AA.
How does it handle colours with transparency?
A translucent text colour is blended over the background it sits on, and a translucent background is blended over white or black, whichever you choose, before anything is scored. The cell detail says when this happened. A background that is translucent over something other than a flat white or black page cannot be scored exactly from a tokens file alone.
Which colour spaces can it read?
Hex, rgb() and hsl() strings, and the 2025.10 colour objects in sRGB, linear sRGB, HSL, HWB, Lab, LCH, Oklab, OKLCH, Display P3, A98 RGB, ProPhoto RGB, Rec. 2020 and XYZ. A colour outside the sRGB gamut is clipped to the nearest colour an sRGB screen can show, and the detail says so. A space it does not convert is scored from the token's hex fallback if it has one, and otherwise the cell says it can't score it.
How does it tell light from dark?
It looks for two groups named light and dark, either at the top of the file or one level down, such as theme.light and theme.dark, and reads each as a mode. It also reads a mode map in a token's $extensions. If it finds neither, it treats the file as one mode. Tokens outside the mode groups, such as a shared palette, are available in every mode.
How does it decide what is text and what is a background?
By the words in a token's name. Names with text, fg, foreground, icon, border or on- are foregrounds and become rows. Names with bg, background, surface, canvas, card or fill are backgrounds and become columns. A name with both, such as on-surface, is a foreground. Anything else goes in both. You can move any token to rows, columns or hide it.
