How to convert colors and check WCAG contrast with an API
Updated 2026-11-10
Use when an agent must convert a color between hex, RGB, HSL, CMYK and OKLCH, or check WCAG contrast.
From an MCP client, add https://tanod.dev/mcp and call convert_color_check_contrast; its free daily calls are applied automatically, no key or signup.
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. For the contrast check alone, POST a foreground and a background to /v1/color/contrast.
Request
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"}'{"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 a common 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.
Contrast only
To check a text color against its background without the conversions, POST foreground and background to /v1/color/contrast (MCP tool check_wcag_contrast). The reply has the ratio and AA / AAA pass or fail for normal text, large text and UI components, from the same calculation: {"foreground":"#777","background":"white"} gives 4.48:1, a pass for large text and UI components and a fail for AA normal text. Same price and free pool.
Price and free allowance
USD 0.001 per call, paid in USDC on Base, Polygon, Solana, BNB Chain or Arbitrum 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.
Use it from Claude without writing code: in claude.ai or Claude Desktop, add https://tanod.dev/mcp/util?via=color-contrast-checker-api as a custom connector (steps), then ask in plain words, for example "Convert #1a73e8 to RGB and HSL, and check its WCAG contrast against white." The free daily allowance is applied automatically over MCP. Beyond it a call needs an x402 payment, which these clients can make.
Related guides: Image color palette API, QR code API. Back to tanod.dev or the guide index.