Color Convert API
OKLab / OKLCH
WCAG Contrast
Palettes

Any color in. Every space out.

Convert hex, named CSS, and functional colors into RGB, HSL, OKLab, contrast scores, and harmony palettes in one call.

hex / rgb / hsl · classicOKLab · perceptualWCAG + APCA · contrasttomato · named CSS

Normalize any color, instantly.

This calls the live Color Convert API. Type a color, pick a swatch, and preview hex, rgb, hsl, and contrast.

Request builder
Any CSS color in, normalized channels out.
GET /color-convert
Accepted inputs
Hex, named CSS colors, rgb(), and hsl(). The live demo sanitizes length and charset before calling the API.
Output preview
Live response from the API, plus the exact request to reproduce it.

Converting color...

Why Color Convert API

Conversion plus accessibility.

Every common color space

Hex, RGB, HSL, HSV, CMYK, XYZ, LAB, OKLab, and OKLCH from one color input.

WCAG and APCA contrast

Ratings against white and black, a recommended text color, and optional contrast_with pairs.

Color-vision simulations

Simulation matrices for common deficiencies so UI tokens can be checked before they ship.

Harmony palettes

Complementary, analogous, triadic, tetradic, split-complementary, plus tints and shades.

CSS gradients

Linear and radial gradient strings with a configurable gradient_angle for design-system output.

Nearest named color

Map any input to the closest CSS named color for documentation and token catalogs.

/api/v1/color-convert

Endpoints, at a glance.

GET or POST a color string and receive RGB, HSL, OKLab, contrast, palettes, and nearest named color.
GET/api/v1/color-convert

Convert a color

Query color (or hex / input / value) plus optional contrast_with and gradient_angle.

PRIMARY
POST/api/v1/color-convert

Convert via JSON

Same conversion with a structured color object or CSS string in the body.

ParameterTypeRequiredDescription
colorstringyes*Hex, named CSS, or functional color. Aliases: input, hex, value.
contrast_withstringnoSecond color for a custom WCAG contrast pair.
gradient_anglenumbernoLinear gradient angle in degrees. Defaults to 90.

Error reference

Failures you can plan for.

Every response includes a success flag and a correlationId for tracing.
400Validation Error

Missing or invalid color input.

401Authentication Error

Missing or invalid gateway API key. Send x-api-key or api_key with every request.

404Not Found

Unknown route under /api/v1/color-convert.

413Payload Too Large

JSON body exceeds 16 KB.

429Rate Limit Error

More than 120 requests in a 15-minute window.

Example error response

{
  "success": false,
  "error": { "code": "VALIDATION_ERROR", "message": "Invalid color" },
  "correlationId": "1784849006651-color01"
}

FAQ

API questions developers ask first.

Which color formats can I send?

Hex values, CSS functions, named colors, and structured channel objects. color, input, hex, and value are accepted aliases.

Does the response include accessibility contrast?

Yes. Every conversion includes WCAG ratings against white and black, a recommended text color, and supplementary APCA scores. Pass contrast_with for a custom pair.

Can I generate palettes and gradients?

The response includes complementary, analogous, triadic, tetradic, split-complementary, monochromatic, tints, shades, plus linear and radial CSS gradients.

Does this extract colors from images?

No. Color Convert is a numeric CSS utility. It does not accept images, store palettes, or manage ICC profiles.

How do I authenticate requests?

Send your Datpaq API key as an x-api-key header or an api_key query parameter. Keys are created in the Datpaq dashboard and a free tier is included.

Normalize any color in one request.

Hex, named CSS, rgb, and hsl in. Hex, rgb, hsl, and contrast ratios out.