Catalog/ref-color-name

Reference

Color name <-> hex + nearest + contrast API

Accept a CSS/X11 color name or a hex string and return canonical hex, RGB, HSL, the nearest named CSS color (Euclidean RGB distance), relative luminance, and the WCAG contrast ratio + AA/AAA pass flags against black and white. The MORE: the full 148-name CSS color table + nearest-color matching + WCAG contrast math LLMs get wrong. Answers 'what is the hex for tomato', 'nearest named color to #ff0001', 'contrast ratio of this color on white', 'is this color AA accessible'.

Price$0.01per request
MethodPOST
Route/v1/ref/color-name
StatusLive
MIME typeapplication/json
Rate limit60/minute
CacheNo cache
refcolorhexcss-colorwcagcontrastrgbnearest-color
API URLhttps://x402.hexl.dev/v1/ref/color-name
Integration docs
Example request
{
  "color": "tomato"
}
Example response
{
  "input": "tomato",
  "name": "tomato",
  "hex": "#ff6347",
  "rgb": {
    "r": 255,
    "g": 99,
    "b": 71
  },
  "hsl": {
    "h": 9,
    "s": 100,
    "l": 64
  },
  "nearestNamed": {
    "name": "tomato",
    "hex": "#ff6347",
    "distance": 0
  },
  "luminance": 0.3447,
  "contrast": {
    "vsWhite": 2.62,
    "vsBlack": 7.89,
    "bestTextColor": "#000000",
    "aaWhite": false,
    "aaBlack": true,
    "aaaWhite": false,
    "aaaBlack": true
  }
}
Input schema
{
  "type": "object",
  "required": [
    "color"
  ],
  "properties": {
    "color": {
      "type": "string",
      "examples": [
        "tomato"
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}