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

FieldTypeRequiredDescription
foregroundstringrequiredForeground (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.
backgroundstringrequiredBackground 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

FieldTypeRequiredDescription
rationumberrequiredUnrounded WCAG contrast ratio, 1–21. Round to 2 decimals for display only — thresholds are evaluated on this exact value.
aa_normalbooleanrequiredWCAG AA for normal text (ratio >= 4.5).
aa_largebooleanrequiredWCAG AA for large text (ratio >= 3.0). Large text is >= 18pt/24px regular or >= 14pt/18.66px bold.
aaa_normalbooleanrequiredWCAG AAA for normal text (ratio >= 7.0).
aaa_largebooleanrequiredWCAG AAA for large text (ratio >= 4.5).
non_text_aabooleanrequiredWCAG 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.