Color Contrast Checker API
Check color contrast against WCAG 2.x AA and AAA thresholds. Live preview, exact ratio, and pass/fail for normal text, large text and UI components. Free, instant.
The Color Contrast Checker is also available as a free REST API. Send a POST request with a JSON body to https://dot.tools/api/tools/contrast-checker — no authentication, no API key, CORS enabled. Successful calls return { "ok": true, "result": { … } }; failures return HTTP 400 or 422 with an error body.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
foreground | string | required | Foreground (text/icon) color. Opaque color as #rgb/#rrggbb, rgb(), hsl(), hwb() or a CSS keyword (e.g. rebeccapurple). Colors with alpha below 1 are rejected — WCAG contrast is defined for opaque colors only. |
background | string | required | Background color. Opaque color as #rgb/#rrggbb, rgb(), hsl(), hwb() or a CSS keyword (e.g. rebeccapurple). Colors with alpha below 1 are rejected — WCAG contrast is defined for opaque colors only. |
Response
| Field | Type | Required | Description |
|---|---|---|---|
ratio | number | required | Unrounded WCAG contrast ratio, 1–21. Round to 2 decimals for display only — thresholds are evaluated on this exact value. |
aa_normal | boolean | required | WCAG AA for normal text (ratio >= 4.5). |
aa_large | boolean | required | WCAG AA for large text (ratio >= 3.0). Large text is >= 18pt/24px regular or >= 14pt/18.66px bold. |
aaa_normal | boolean | required | WCAG AAA for normal text (ratio >= 7.0). |
aaa_large | boolean | required | WCAG AAA for large text (ratio >= 4.5). |
non_text_aa | boolean | required | WCAG 1.4.11 non-text/UI components (ratio >= 3.0). |
Example request
curl -X POST https://dot.tools/api/tools/contrast-checker \
-H 'Content-Type: application/json' \
-d '{
"foreground": "#663399",
"background": "#ffffff"
}'Sample response
{
"ok": true,
"result": {
"ratio": 8.405149896230322,
"aa_normal": true,
"aa_large": true,
"aaa_normal": true,
"aaa_large": true,
"non_text_aa": true
}
}Use the free Color Contrast Checker in your browser, read the Color Contrast Checker guide, or import the full OpenAPI specification.