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
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | string | Yes | The 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
| Field | Type | Description |
|---|---|---|
| valid | boolean | Whether the value is a recognised CSS color string |
| format | string | Detected input format: hex, rgb, or hsl. Only present when valid is true. |
| r / g / b | number | Red, green, blue components (0–255). Only present when valid is true. |
| h | number | Hue (0–360). Only present when valid is true. |
| s | number | Saturation (0–100). Only present when valid is true. |
| l | number | Lightness (0–100). Only present when valid is true. |
| alpha | number | Opacity (0–1). Defaults to 1 when no alpha channel is specified. Only present when valid is true. |
| hex | string | Normalised 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"
}