# WCAG 2.1 Contrast Ratio Calculator

> WCAG 2.1 Contrast Ratio Calculator is a paid API for AI agents from color.agentutil.net, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-10, last successful call 2026-04-29).

Calculates the WCAG 2.1 contrast ratio between a foreground and background color, and returns pass/fail results for AA and AAA accessibility standards at normal and large text sizes.

## Facts

- Endpoint: POST https://color.agentutil.net/v1/contrast?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-10
- Last successful call: 2026-04-29
- Success rate: 100% of calls made through Zero
- Activations on Zero: 4
- Tags: x402
- Canonical page: https://www.zero.xyz/c/color-agentutil-net-4ec2ac32
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_RBK2tYl9P-j4Ov11tRzr9

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability color-agentutil-net-4ec2ac32 -d '<json body>'
```

Example prompt: What's the WCAG 2.1 contrast ratio between a white background (#FFFFFF) and dark navy foreground (#1A2E4A), and does it pass AA and AAA standards for both normal and large text?

## When to prefer this

Use this endpoint when you need to programmatically verify color accessibility compliance per WCAG 2.1 — especially when building or auditing UI components, design systems, or web pages and need pass/fail verdicts across all four WCAG contrast thresholds (AA/AAA × normal/large text) in a single call. Prefer this over manual calculation or generic color tools when you need structured, machine-readable results including the numeric ratio and boolean compliance flags.

## Known failure modes

- Invalid color format provided — returns error if hex, rgb(), hsl(), or CSS name cannot be parsed
- Missing required field (background or foreground) — returns validation error
- Unrecognized CSS color name — returns parsing error

## How this service works

Calculate WCAG 2.1 contrast ratio between two colors

## Output

Returns a numeric contrast ratio (e.g. 21 for black-on-white), boolean pass/fail flags for WCAG 2.1 AA and AAA compliance at both normal and large text sizes, the normalized hex values of the input colors, a request ID, and a list of related agentutil services.

## Example request

```json
{
 "background": "#FFFFFF",
 "foreground": "#000000"
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "background": {
   "type": "string",
   "description": "Background color (hex, rgb(), hsl(), or CSS name)"
  },
  "foreground": {
   "type": "string",
   "description": "Foreground color (hex, rgb(), hsl(), or CSS name)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "ratio",
  "service",
  "aa_large",
  "aa_normal",
  "aaa_large",
  "aaa_normal",
  "background",
  "foreground",
  "request_id",
  "related_services"
 ],
 "properties": {
  "ratio": {
   "type": "number"
  },
  "service": {
   "type": "string"
  },
  "aa_large": {
   "type": "boolean"
  },
  "aa_normal": {
   "type": "boolean"
  },
  "aaa_large": {
   "type": "boolean"
  },
  "aaa_normal": {
   "type": "boolean"
  },
  "background": {
   "type": "string"
  },
  "foreground": {
   "type": "string"
  },
  "request_id": {
   "type": "string"
  },
  "related_services": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "url",
     "name",
     "description"
    ],
    "properties": {
     "url": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "description": {
      "type": "string"
     }
    }
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/color-agentutil-net-4ec2ac32/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from color.agentutil.net](https://www.zero.xyz/host/color.agentutil.net/llms.txt)
