# Colour converter

Convert a colour between hex, RGB, HSL, HWB, OKLab and OKLCH, and find the nearest CSS colour name.

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

## Inputs

- `color` (required, string): A colour in any CSS format: hex, rgb(), hsl(), hwb(), oklab(), oklch() or a name.

## Example 1

```json
{"input":{"color":"#ff0000"}}
```

Result:

```json
{"hex":"#ff0000","rgb":"rgb(255, 0, 0)","hsl":"hsl(0, 100%, 50%)","hwb":"hwb(0 0% 0%)","oklab":"oklab(0.628 0.2249 0.1258)","oklch":"oklch(0.628 0.2577 29.23)","alpha":1,"red":255,"green":0,"blue":0,"name":"red","nearest_name":"red","in_gamut":true}
```

## Example 2: HSL to everything else

```json
{"input":{"color":"hsl(270, 50%, 40%)"}}
```

Result:

```json
{"hex":"#663399","rgb":"rgb(102, 51, 153)","hsl":"hsl(270, 50%, 40%)","hwb":"hwb(270 20% 40%)","oklab":"oklab(0.4403 0.0882 -0.1339)","oklch":"oklch(0.4403 0.1603 303.37)","alpha":1,"red":102,"green":51,"blue":153,"name":"rebeccapurple","nearest_name":"rebeccapurple","in_gamut":true}
```

**Which colour formats can I type?** Hex (#rgb, #rrggbb, #rrggbbaa), rgb() and rgba(), hsl() and hsla(), hwb(), oklab(), oklch(), and any of the 148 CSS colour names such as "rebeccapurple".

**What does "in_gamut" mean?** OKLab and OKLCH can describe colours that an ordinary sRGB screen cannot show. When that happens the colour is clipped to the nearest displayable value and in_gamut is false.

**How is the nearest name chosen?** By the smallest distance in OKLab, which matches how different two colours look better than comparing RGB numbers.
