CSS gradient generator
Build a CSS linear, radial or conic gradient from a list of colour stops, with an SVG preview.
Input
Result
Fill in the input and press Run.
Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.
Use it from code or an agent
curl -s https://setget.net/v1/tools/css-gradient \
-H 'Content-Type: application/json' \
-d '{"input":{"stops":["#ff0000","#0000ff"],"angle":90}}'
import json, urllib.request
body = {'input': {'stops': ['#ff0000', '#0000ff'], 'angle': 90}}
request = urllib.request.Request("https://setget.net/v1/tools/css-gradient", json.dumps(body).encode(),
{"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/css-gradient", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"input":{"stops":["#ff0000","#0000ff"],"angle":90}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
"slug": "css-gradient",
"input": {
"stops": [
"#ff0000",
"#0000ff"
],
"angle": 90
}
}
{
"input": {
"stops": [
"#ff0000",
"#0000ff"
],
"angle": 90
}
}
Endpoint: POST /v1/tools/css-gradient. Over MCP: run_tool with slug: "css-gradient".
Machine-readable: input schema, Markdown. Connect an agent.
Inputs
| Name | Type | Required | What it does |
|---|---|---|---|
stops |
array | yes | Two or more colours in order. Add a position to any of them, as in "#ff0000 25%". |
type |
string | no | Kind of gradient. One of: linear, radial, conic. Default: "linear". |
angle |
number | no | Angle in degrees. For linear, 0 points up and 90 points right (default 180). For conic, the starting angle (default 0). From -3600 to 3600. |
direction |
string | no | For linear gradients, a direction such as "to right" or "to bottom left" instead of an angle. |
shape |
string | no | For radial gradients, the shape. One of: ellipse, circle. Default: "ellipse". |
Examples
Input
{
"stops": [
"#ff0000",
"#0000ff"
],
"angle": 90
}Result
{
"css": "linear-gradient(90deg, #ff0000, #0000ff)",
"declaration": "background: linear-gradient(90deg, #ff0000, #0000ff);",
"stops": [
{
"color": "#ff0000",
"position": 0
},
{
"color": "#0000ff",
"position": 100
}
],
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"120\" height=\"120\" viewBox=\"0 0 120 120\"><defs><linearGradient id=\"g\" x1=\"0\" y1=\"0.5\" x2=\"1\" y2=\"0.5\"><stop offset=\"0%\" stop-color=\"#ff0000\"/><stop offset=\"100%\" stop-color=\"#0000ff\"/></linearGradient></defs><rect width=\"120\" height=\"120\" fill=\"url(#g)\"/></svg>"
}Radial with a positioned stop
Input
{
"stops": [
"gold",
"tomato 30%",
"rebeccapurple"
],
"type": "radial",
"shape": "circle"
}Result
{
"css": "radial-gradient(circle, #ffd700, #ff6347 30%, #663399)",
"declaration": "background: radial-gradient(circle, #ffd700, #ff6347 30%, #663399);",
"stops": [
{
"color": "#ffd700",
"position": 0
},
{
"color": "#ff6347",
"position": 30
},
{
"color": "#663399",
"position": 100
}
]
}Questions
- Which colour formats can I type?
- Hex (#rgb, #rrggbb, #rrggbbaa), rgb() and rgba(), hsl() and hsla(), hwb(), oklab(), oklch(), and any of the 148 CSS colour names such as "rebeccapurple".
- Which way does the angle point?
- As in CSS: 0deg runs bottom to top, 90deg left to right, 180deg top to bottom.
- Where do stops without a position go?
- The first is at 0%, the last at 100%, and the rest are spread evenly between their neighbours, exactly as browsers do.
- Why is there no SVG for radial and conic?
- The preview is only made for linear gradients. SVG has no conic gradient, and its radial one is sized differently from CSS.
Related tools
- Colour converterConvert a colour between hex, RGB, HSL, HWB, OKLab and OKLCH, and find the nearest CSS colour name.
color-convert - Colour palette generatorBuild colour schemes from one base colour: complementary, analogous, triadic and a 50 to 950 shade scale.
palette-generate - Colour mixerMix two colours by any ratio in sRGB or OKLab, or lighten or darken a colour by a percentage.
color-blend - Add or subtract time from a dateAdd or subtract years, months, weeks, days, hours and minutes from a date and get the resulting date.
date-add - Age calculatorWork out an exact age in years, months and days on a given date, plus the next birthday.
age-calculator - Aspect ratio calculatorSimplify a width and height to a ratio such as 16:9, and scale to a new width or height.
aspect-ratio