# Colour contrast checker

Check the WCAG contrast ratio between text and background colours, with AA and AAA pass or fail.

- Endpoint: `POST https://setget.net/v1/tools/contrast-ratio` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `contrast-ratio`
- Page: https://setget.net/tools/contrast-ratio

## Inputs

- `foreground` (required, string): The text colour, in any CSS format.
- `background` (required, string): The background colour, in any CSS format.

## Example 1

```json
{"input":{"foreground":"#000000","background":"#ffffff"}}
```

Result:

```json
{"ratio":21,"text":"21:1","foreground":"#000000","background":"#ffffff","aa":{"normal":true,"large":true},"aaa":{"normal":true,"large":true},"ui_components":true,"suggestion":null}
```

## Example 2: A grey that just fails

```json
{"input":{"foreground":"#777777","background":"#ffffff"}}
```

Result:

```json
{"ratio":4.47,"text":"4.47:1","foreground":"#777777","background":"#ffffff","aa":{"normal":false,"large":true},"aaa":{"normal":false,"large":false},"ui_components":true,"suggestion":{"foreground":"#767676","ratio":4.54,"passes":"AA"}}
```

**What ratios are needed?** AA needs 4.5:1 for normal text and 3:1 for large text. AAA needs 7:1 and 4.5:1. Icons and interface components need 3:1.

**What counts as large text?** At least 18 point (24 px), or 14 point (about 18.7 px) when bold.

**Why does 4.47 not round up to pass?** WCAG compares the exact ratio, so 4.499 fails 4.5. The ratio shown is cut to two decimals, never rounded up.

**How is the suggestion chosen?** It keeps the hue and saturation of your text colour and changes the lightness by the smallest amount that reaches AA for normal text.

**What about transparent colours?** A see-through foreground is blended over the background first, and a see-through background is blended over white.
