Colour converter

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

Input

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

Result

Fill in the input and press Run.

Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.

Use it from code or an agent

curl -s https://setget.net/v1/tools/color-convert \
  -H 'Content-Type: application/json' \
  -d '{"input":{"color":"#ff0000"}}'
import json, urllib.request

body = {'input': {'color': '#ff0000'}}
request = urllib.request.Request("https://setget.net/v1/tools/color-convert", json.dumps(body).encode(),
                                 {"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/color-convert", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"color":"#ff0000"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "color-convert",
  "input": {
    "color": "#ff0000"
  }
}
{
  "input": {
    "color": "#ff0000"
  }
}

Endpoint: POST /v1/tools/color-convert. Over MCP: run_tool with slug: "color-convert". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
color string yes A colour in any CSS format: hex, rgb(), hsl(), hwb(), oklab(), oklch() or a name.

Examples

Input
{
  "color": "#ff0000"
}
Result
{
  "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
}

HSL to everything else

Input
{
  "color": "hsl(270, 50%, 40%)"
}
Result
{
  "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
}

Questions

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.