Colour converter
Convert a colour between hex, RGB, HSL, HWB, OKLab and OKLCH, and find the nearest CSS colour name.
Input
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
| Name | Type | Required | What 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.
Related tools
- Colour contrast checkerCheck the WCAG contrast ratio between text and background colours, with AA and AAA pass or fail.
contrast-ratio - Colour palette generatorBuild colour schemes from one base colour: complementary, analogous, triadic and a 50 to 950 shade scale.
palette-generate - Colour mixerMix two colours by any ratio in sRGB or OKLab, or lighten or darken a colour by a percentage.
color-blend - CSS gradient generatorBuild a CSS linear, radial or conic gradient from a list of colour stops, with an SVG preview.
css-gradient - Add or subtract time from a dateAdd or subtract years, months, weeks, days, hours and minutes from a date and get the resulting date.
date-add - Age calculatorWork out an exact age in years, months and days on a given date, plus the next birthday.
age-calculator