
CSS Gradient Generator API
Design
Free CSS gradient generator with real-time preview. Create linear and radial gradients for UI design. Copy CSS code instantly.
Authentication
All API requests require a valid API key passed in the Authorization header as a Bearer token.
Rate Limit
120 requests per minute
Endpoints
1 endpoint available
Overview
Build a CSS linear or radial gradient from colour stops. The response has the one-line value (for
background) and a multi-line declaration ready to paste.
Notes
- Send 2 to 20 colour stops. Each has a
colorand apositionfrom 0 to 100 (percent). Stops are sorted by position in the output. angle(0 to 360 degrees) applies to linear gradients only. Radial gradients are circles.- Colours can be hex, a colour name, or an
rgb(),hsl(),hwb(),lab(),lch(),oklab()oroklch()function. Anything else is rejected.
Endpoints
POST
https://opentools.ca/api/v1/tools/css-gradient-generatorGenerate a CSS gradient
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| type | string Enum: linear, radial | Optional | Gradient type.Default: linear |
| angle | number | Optional | Angle in degrees, 0 to 360. Linear gradients only.Default: 90 |
| colorStops | object[] | Required | 2 to 20 objects, each with color (string, required) and position (number from 0 to 100, required). |
Response Example
{
"success": true,
"value": "linear-gradient(90deg, #ff0000 0%, #0000ff 100%)",
"css": "background: linear-gradient(90deg,\n #ff0000 0%,\n #0000ff 100%\n);"
}Error Codes
400
Bad Request - Fewer than 2 or more than 20 stops, out-of-range number, or unsupported colour401
Unauthorized - Invalid or missing API key403
Forbidden - API key inactive, expired, or request from a disallowed IP429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode Examples
curl -X POST https://opentools.ca/api/v1/tools/css-gradient-generator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "linear", "angle": 135, "colorStops": [{"color": "#ff0000", "position": 0}, {"color": "#0000ff", "position": 100}]}'Rather use it in your browser? Open the CSS Gradient Generator