WCAG Text Contrast Checker

WCAG Text Contrast Checker API

Accessibility

Check colour contrast ratios to ensure accessibility compliance with WCAG guidelines (Level AA and AAA).

Authentication

All API requests require a valid API key passed in the Authorization header as a Bearer token.

Rate Limit

100 requests per minute

Endpoints

2 endpoints available

Overview

The WCAG Text Contrast Checker API validates colour contrast ratios against Web Content Accessibility Guidelines (WCAG). Check if your text and background colour combinations meet Level AA or AAA compliance standards.

WCAG Standards

  • Level AA (Normal Text) - Minimum contrast ratio of 4.5:1
  • Level AA (Large Text) - Minimum contrast ratio of 3:1 (18pt+ or 14pt bold)
  • Level AAA (Normal Text) - Minimum contrast ratio of 7:1
  • Level AAA (Large Text) - Minimum contrast ratio of 4.5:1

Check Types

  • WCAG Compliance - Check against AA and AAA standards with font size consideration
  • Custom Ratio - Check against a custom minimum contrast ratio
  • Batch Check - Check multiple colour pairs at once

Use Cases

  • Web design accessibility audits
  • Design system colour validation
  • Automated accessibility testing pipelines
  • UI/UX design reviews
  • Brand colour accessibility verification

Endpoints

POST
/v1/tools/wcag-text-checker
Check colour contrast for WCAG compliance

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
textColour
string
Required
Text colour in hex format (e.g., "#000000")
backgroundColour
string
Required
Background colour in hex format (e.g., "#FFFFFF")
fontSize
number
OptionalFont size in pixels (used to determine large text threshold)Default: 14
checkType
string
Enum: wcag, custom
OptionalType of check to performDefault: wcag
customRatio
number
OptionalCustom minimum contrast ratio (1-21, only used when checkType is "custom")Default: 4.5

Response Example

{
  "success": true,
  "contrastRatio": "12.63",
  "wcagAA": true,
  "wcagAAA": true,
  "textColour": "#1a1a1a",
  "backgroundColour": "#ffffff",
  "fontSize": 16,
  "isLargeText": false
}

Error Codes

400
Invalid colour format or missing required parameters
401
Missing or invalid API key
429
Rate limit exceeded
500
Internal server error
POST
/v1/tools/wcag-text-checker/batch
Check multiple colour pairs at once

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
pairs
array
Required
Array of colour pairs to check, each with textColour, backgroundColour, and optional fontSize

Response Example

{
  "success": true,
  "results": [
    {
      "textColour": "#000000",
      "backgroundColour": "#ffffff",
      "contrastRatio": "21.00",
      "wcagAA": true,
      "wcagAAA": true
    },
    {
      "textColour": "#666666",
      "backgroundColour": "#ffffff",
      "contrastRatio": "5.74",
      "wcagAA": true,
      "wcagAAA": false
    }
  ]
}

Error Codes

400
Invalid colour format or empty pairs array
401
Missing or invalid API key
429
Rate limit exceeded
500
Internal server error

Code Examples

# Single colour pair check
curl -X POST https://api.opentools.ca/v1/tools/wcag-text-checker \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"textColour": "#333333", "backgroundColour": "#f5f5f5", "fontSize": 16}'

# Batch check multiple pairs
curl -X POST https://api.opentools.ca/v1/tools/wcag-text-checker/batch \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pairs": [{"textColour": "#000000", "backgroundColour": "#ffffff"}, {"textColour": "#0066cc", "backgroundColour": "#ffffff"}]}'

Ready to get started?

Create an API key to start using the WCAG Text Contrast Checker API.