Skip to main content

Endpoint

POST https://api.bunny.build/api/v1/color-converter

Authentication

HeaderRequiredValue
X-API-KeyYesYour API key (bun_...)
Content-TypeYesapplication/json

Overview

Convert colors between HEX, RGB, and HSL formats instantly. Submit a color in any of the three supported formats and receive the equivalent values in all three, eliminating manual conversion math in design tools, theming systems, and CSS generators.

Use cases

  • Convert brand colors between formats for cross-platform design systems
  • Generate CSS custom properties in all formats from a single source
  • Validate color inputs in design or configuration UIs
  • Transform palette exports from design tools into developer-friendly formats

Details

HEX values should include the # prefix (e.g. #ff5733). RGB components are integers 0–255. HSL hue is 0–360 degrees; saturation and lightness are percentages 0–100.

Request body

Provide exactly one of hex, rgb, or hsl.
FieldTypeRequiredDescription
hexstringNoHex color string (e.g. #ff5733)
rgbobjectNoRGB object with r, g, b integer fields (0–255)
hslobjectNoHSL object with h (0–360), s (0–100), l (0–100) fields

Example — from HEX

{
  "hex": "#ff5733"
}

Example — from RGB

{
  "rgb": { "r": 255, "g": 87, "b": 51 }
}

Example — from HSL

{
  "hsl": { "h": 11, "s": 100, "l": 60 }
}

Response

200 OK

FieldTypeDescription
hexstringHEX representation (uppercase, e.g. #FF5733)
rgbobjectRGB object with integer fields r, g, b (0–255)
hslobjectHSL object with integer fields h (0–360), s (0–100), l (0–100)
cmykobjectCMYK object with integer fields c, m, y, k (0–100)
cssobjectReady-to-use CSS strings: hex (string), rgb (e.g. "rgb(255, 87, 51)"), hsl (e.g. "hsl(11, 100%, 60%)")
Example
{
  "hex": "#FF5733",
  "rgb": { "r": 255, "g": 87, "b": 51 },
  "hsl": { "h": 11, "s": 100, "l": 60 },
  "cmyk": { "c": 0, "m": 66, "y": 80, "k": 0 },
  "css": {
    "hex": "#FF5733",
    "rgb": "rgb(255, 87, 51)",
    "hsl": "hsl(11, 100%, 60%)"
  }
}

401 Unauthorized

{
  "detail": "Missing API key. Include X-API-Key header."
}

402 Payment Required

{
  "detail": "Monthly quota exceeded. Upgrade your plan."
}

422 Unprocessable Entity

{
  "detail": "Provide exactly one of: hex, rgb, hsl"
}

429 Too Many Requests

{
  "detail": "Rate limit exceeded. Try again in 60 seconds."
}

cURL example

curl -X POST https://api.bunny.build/api/v1/color-converter \
  -H "X-API-Key: bun_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"hex": "#ff5733"}'