CSS Gradient Generator

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 color and a position from 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() or oklch() function. Anything else is rejected.

Endpoints

POST
https://opentools.ca/api/v1/tools/css-gradient-generator
Generate a CSS gradient

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
type
string
Enum: linear, radial
OptionalGradient type.Default: linear
angle
number
OptionalAngle 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 colour
401
Unauthorized - Invalid or missing API key
403
Forbidden - API key inactive, expired, or request from a disallowed IP
429
Too Many Requests - Rate limit exceeded
500
Internal Server Error

Code 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}]}'

Ready to get started?

Create an API key to start using the CSS Gradient Generator API.

Rather use it in your browser? Open the CSS Gradient Generator