Color

GET/v0/color

Validates and parses a CSS color string in hex, RGB, or HSL format. Automatically detects the input format and returns all three representations together with the alpha channel. Supports shorthand hex (#rgb), full hex (#rrggbb), hex with alpha (#rrggbbaa), rgb(), rgba(), hsl(), and hsla().

Try it

Query Parameters

ParameterTypeRequiredDescription
valuestringYesThe CSS color string to validate and parse

Example Request

curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.isvalid.dev/v0/color?value=%23ff0000"

Response Fields

FieldTypeDescription
validbooleanWhether the value is a recognised CSS color string
formatstringDetected input format: hex, rgb, or hsl. Only present when valid is true.
r / g / bnumberRed, green, blue components (0–255). Only present when valid is true.
hnumberHue (0–360). Only present when valid is true.
snumberSaturation (0–100). Only present when valid is true.
lnumberLightness (0–100). Only present when valid is true.
alphanumberOpacity (0–1). Defaults to 1 when no alpha channel is specified. Only present when valid is true.
hexstringNormalised hex representation (#rrggbb or #rrggbbaa when alpha < 1). Only present when valid is true.

Example Response

{
  "valid": true,
  "format": "hex",
  "r": 255,
  "g": 0,
  "b": 0,
  "h": 0,
  "s": 100,
  "l": 50,
  "alpha": 1,
  "hex": "#ff0000"
}