
Colour Converter API
Design
Convert HEX, RGB, HSL and named colours to other formats, including CMYK, with a colour picker and text contrast detection.
Authentication
All API requests require a valid API key passed in the Authorization header as a Bearer token.
Rate Limit
120 requests per minute
Endpoints
1 endpoint available
Overview
Send a colour in any supported format and get it back as HEX, RGB, RGBA, HSL, HSLA, CMYK, Display P3 and LCH, along with a colour name and a suggested text colour (black or white) for use on top of it. The endpoint accepts GET with a query parameter or POST with a JSON body.
Supported input
- HEX: #FF5733, #f53, FF5733, or 8 digits with alpha such as #FF573380
- RGB and RGBA: rgb(255, 87, 51), rgba(255, 87, 51, 0.8)
- HSL and HSLA: hsl(9, 100%, 60%), hsla(9, 100%, 60%, 0.8). Use whole numbers.
- Named colours: red, tomato, coral and the other names in the colour list. Case and spaces are ignored.
Response fields
input: the colour you senthex,rgb,rgba,hsl,hsla,cmyk,displayP3,lch: CSS-style stringschannels:r,g,bas 0-255 integers andaas 0-1 (1 when no alpha was given)name: the exact name from the colour list when there is one, otherwise a general family such as Red or GraybestTextColor: "black" or "white", whichever reads better on this colour
Notes
- Input is limited to 100 characters. RGB channels must be 0-255 and alpha 0-1, or you get a 400.
- Colours given as rgb() or hsl() are treated as having an alpha of 1, so their
hexvalue ends in an alpha pair such as FF. A plain HEX input without alpha has no alpha pair. - HSL and CMYK values are rounded to whole numbers.
Endpoints
POST
https://opentools.ca/api/v1/tools/colour-converterConvert a colour to every supported format. GET with ?colour=... also works.
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| colour | string | Required | The colour to convert, 1-100 characters, in any supported format |
Response Example
{
"success": true,
"input": "#FF5733",
"hex": "#FF5733",
"rgb": "rgb(255, 87, 51)",
"rgba": "rgba(255, 87, 51, 1)",
"hsl": "hsl(11, 100%, 60%)",
"hsla": "hsla(11, 100%, 60%, 1)",
"cmyk": "cmyk(0, 66, 80, 0)",
"displayP3": "color(display-p3 0.93 0.39 0.26)",
"lch": "lch(2.56 8.29 25.11)",
"channels": {
"r": 255,
"g": 87,
"b": 51,
"a": 1
},
"name": "Red",
"bestTextColor": "black"
}Error Codes
400
Bad Request - Missing, unrecognised or out-of-range colour401
Unauthorized - Invalid or missing API key403
Forbidden - API key is inactive or expired, or the request IP is not allowed429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode Examples
curl -X POST https://opentools.ca/api/v1/tools/colour-converter \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"colour": "#FF5733"}'
# GET works too
curl "https://opentools.ca/api/v1/tools/colour-converter?colour=tomato" \
-H "Authorization: Bearer YOUR_API_KEY"Rather use it in your browser? Open the Colour Converter