Color Format Conversion

Convert color values between HEX, RGB, HSL, and CMYK formats. Every response includes all four representations so you never need to call more than once.

Get API Key

Overview

Use Cases

  • Convert design tool color exports into CSS-ready values
  • Build color palette generators and pickers
  • Normalize color inputs from different user sources into a single format
  • Populate design system tokens from brand color values
  • Inspect color relationships between HEX codes and their HSL equivalents

Features

Converts between HEX, RGB, HSL, and CMYK in a single call
Returns all four formats simultaneously β€” no need for multiple requests
Accepts shorthand HEX notation (e.g. "#f53" β†’ "#ff5533")
Flexible input parsing β€” whitespace-tolerant for rgb() and hsl() strings
Zero external dependencies β€” fast, in-memory conversion

API Endpoints

Convert Color

Convert a color value from one format to another. The response always includes all four formats.

GET
https://api.requiems.xyz/v1/convert/color

Parameters

Name Type Required Description
from string Required Source color format: hex, rgb, hsl, or cmyk
to string Required Target color format: hex, rgb, hsl, or cmyk
value string Required Color value in the source format (e.g. #ff5733, rgb(255,87,51), hsl(11,100%,60%), cmyk(0%,66%,80%,0%))

Try it out

Live Demo
Request

Source color format: hex, rgb, hsl, or cmyk

Target color format: hex, rgb, hsl, or cmyk

Color value in the source format (e.g. #ff5733, rgb(255,87,51), hsl(11,100%,60%), cmyk(0%,66%,80%,0%))

Response Fields

Field Type Description
input string The original value passed in the value parameter
result string The color expressed in the requested to format
formats.hex string HEX representation (#rrggbb)
formats.rgb string RGB representation (rgb(r, g, b))
formats.hsl string HSL representation (hsl(h, s%, l%))
formats.cmyk string CMYK representation (cmyk(c%, m%, y%, k%))

Code Examples

# HEX to HSL
curl "https://api.requiems.xyz/v1/convert/color?from=hex&to=hsl&value=%23ff5733" \
  -H "requiems-api-key: YOUR_API_KEY"

# RGB to CMYK
curl "https://api.requiems.xyz/v1/convert/color?from=rgb&to=cmyk&value=rgb(255%2C87%2C51)" \
  -H "requiems-api-key: YOUR_API_KEY"

# HSL to HEX
curl "https://api.requiems.xyz/v1/convert/color?from=hsl&to=hex&value=hsl(120%2C100%25%2C50%25)" \
  -H "requiems-api-key: YOUR_API_KEY"

Error Responses

bad_request

One or more of from, to, or value parameters is missing or the from/to value is not one of: hex, rgb, hsl, cmyk.

invalid_color

The value cannot be parsed in the specified from format.

internal_error

Unexpected server error.

Frequently Asked Questions