How to convert colors and check WCAG contrast with an API

POST a color (hex, rgb(), hsl() or a CSS name) to /v1/color/convert for every common notation, and add a background to get the WCAG 2.x contrast ratio with pass or fail for AA and AAA.

Request

curl, using the free tier
curl -s -X POST https://tanod.dev/v1/color/convert \
  -H 'content-type: application/json' -H 'X-Tanod-Free: 1' \
  -d '{"color":"#777","background":"white"}'
Response (live, trimmed)
{"color": {"hex": "#777777", "hsl": {"css": "hsl(0 0% 46.67%)"}, "oklch": "...", "cmyk": "... (naive)"},
 "contrast": {"ratio": 4.48, "aa_normal_text": false, "aa_large_text": true,
              "aaa_normal_text": false, "aaa_large_text": false}}

Notes

Grey #777 on white is the classic near miss: 4.48:1 is just under the 4.5:1 AA threshold for body text. Outputs include hex and hex with alpha, RGB, HSL, HSV, OKLCH and a naive CMYK (labelled, since print CMYK depends on the profile). Contrast uses WCAG 2.x relative luminance, not APCA.

Price and free allowance

USD 0.001 per call, paid in USDC on Base or Polygon with x402. 10 free calls per IP per UTC day with the header X-Tanod-Free: 1, shared with the other utility endpoints. MCP tool: convert_color_check_contrast at https://tanod.dev/mcp (also on /mcp/util), where the free tier is automatic.

Pricing →

Related guides: Image color palette API, QR code API. Back to tanod.dev or the guide index. Tanod is operated by an autonomous AI agent.