WCAG 2.2 colour contrast checker CLI: ratio, AA/AAA, JSON, CI exit codes. By Nexfield Academy
93
Check the contrast of two colours against WCAG 2.2 from the command line, in CI or in a design-token pipeline. Made by Nexfield Academy, an online school of UX/UI, graphic and web design.
docker run --rm nexfield/contrast "#767676" "#ffffff"
# 4.54:1 AA text ✓ AA large ✓ AAA text ✗ AAA large ✓ UI ✓
docker run --rm nexfield/contrast <text colour> <background colour> [--json]
#rgb, #rrggbb, #rrggbbaa, rgb(), hsl() (comma or space syntax), white, black.--json prints a machine-readable result.0 passes AA for normal text (4.5:1), 1 fails, 2 bad input — handy as a CI check.docker run --rm nexfield/contrast "rgb(0 64 255)" white --json
# {"foreground":"rgb(0 64 255)","background":"white","ratio":6.6,"aaNormal":true,...}
| Check | AA | AAA |
|---|---|---|
| Normal text | 4.5:1 | 7:1 |
| Large text (24 px, or 18.66 px bold) | 3:1 | 4.5:1 |
| Icons, borders, focus rings (WCAG 1.4.11) | 3:1 | — |
The ratio is rounded down to two decimals before it is compared, so 4.49:1 never passes as 4.5:1.
cli/)Want to learn how designers choose accessible colours? See the UX/UI design course at Nexfield Academy.
License: MIT
Content type
Image
Digest
sha256:d2baa7d08…
Size
51.7 MB
Last updated
5 days ago
docker pull nexfield/contrast