# Convert a hex color to RGB or HSL from an AI agent

You need a CSS color written in another notation: hex to rgb(), rgb() to hsl(), or hsl() back to hex.

Use `color-convert@1.0.0`. It is free and needs no key or sign-up. Converts hex, rgb(), hsl(), or hwb() colors and returns the requested normalized notation.

## Why call a tool for this

Hue and saturation arithmetic is easy to get slightly wrong, and a near-miss color still looks plausible. The tool parses the color and returns the requested notation. For example, #ff8800 to hsl returns hsl(32 100% 50%).

## Call it over HTTP

```sh
curl -X POST https://computefirst.net/v1/tools/color-convert/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"color":"#ff8800","format":"rgb"}'
```

Response:

```json
{
  "result": {
    "standard_version": "CSS Color 4 (2024-02-14); WCAG 2.2",
    "format": "rgb",
    "value": "rgb(255 136 0)"
  }
}
```

## Call it over MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "color-convert",
  "version": "1.0.0",
  "input": {
    "color": "#ff8800",
    "format": "rgb"
  }
}
```

## Check the result

Input is hex, rgb(), hsl() or hwb(); named colors such as red and the legacy rgba() and hsla() forms are not accepted. Output formats are hex, rgb, hsl and hwb. A color with transparency keeps its alpha, so rgb(255 0 0 / 50%) to hex returns #ff000080.

Full contract, limits and unsupported cases: [Color convert](/tools/color-convert).

## Related tools

- [Color adjust lightness](/tools/color-adjust-lightness)
