Gradient Generator

Pick a type, set the colours and where they sit, and copy the CSS. Mesh mode layers soft colour blobs for the blurred, many-colour look.

How it works

A CSS gradient is an image the browser paints from a short recipe: a type, a direction or a centre, and a list of colour stops. Nothing is downloaded, and it stays sharp at any size because it is redrawn rather than stretched.

Linear gradients run along a line at an angle. Radial gradients spread out from a centre point. Conic gradients sweep around a centre like the hand of a clock. A mesh gradient is not its own CSS type: it is several radial gradients stacked on top of each other, each fading to transparent, over a base colour.

The tool writes a background-color line before the gradient. For a mesh it is the colour the blobs fade into; for the others it is what a very old browser shows instead of a blank box.

How to use it

  1. 1 Pick Linear, Radial, Conic or Mesh.
  2. 2 Set the colours and their positions. For a mesh, set where each blob sits and how far it reaches.
  3. 3 Change the angle or the centre and watch the preview.
  4. 4 Copy the CSS and paste it into your stylesheet.

Good to know

  • Stops that share a position make a hard edge instead of a blend: red 50%, blue 50% gives two flat halves.
  • A gradient between two saturated opposites, such as red and green, can look muddy in the middle. Add a third stop in between to steer it.
  • Conic gradients with hard stops make pie charts and colour wheels with no images at all.
  • Need the gradient as a picture, for a slide or a wallpaper? The Background Generator paints the same gradient to a PNG at any size.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

How the browser turns "90deg" into a line, worked through by hand

Take the gradient linear-gradient(90deg, #ff7a45 0%, #3d5afe 100%) on a box 200 pixels wide and 100 pixels tall. The angle says which way the gradient runs. In CSS, 0deg points straight up and angles turn clockwise, so 90deg points to the right. The gradient line goes through the centre of the box, at (100, 50), in that direction, and the first colour sits at its start, the second at its end.

The interesting part is how long that line is. CSS makes it exactly long enough that the corners of the box get the pure end colours. The formula is the width times the sine of the angle plus the height times the cosine, both taken as positive numbers. At 90deg the sine is 1 and the cosine is 0, so the line is 200 × 1 + 100 × 0 = 200 pixels long: it runs from the left edge at (0, 50) to the right edge at (200, 50). Halfway along, at x = 100, the colour is an even mix of orange and blue.

Now turn the same box to 45deg. The sine and cosine are both about 0.7071, so the line is 200 × 0.7071 + 100 × 0.7071, or about 212 pixels, longer than either side. That stretch is what makes the bottom-left corner pure orange and the top-right corner pure blue. Canvas drawing in JavaScript does not do this for you; it draws a gradient between two points you name. The Background Generator on this site uses this exact sum to paint a PNG that matches the CSS, and its test suite checks a 45deg line in a 100 by 100 square comes out at 141.42 pixels.

Radial gradients have a similar hidden default. Unless you say otherwise, the shape is an ellipse sized to reach the farthest corner of the box. From the centre of a 200 by 100 box, the farthest side is 100 pixels away across and 50 pixels down, and the ellipse is those two figures multiplied by the square root of 2, about 141 by 71 pixels, so its edge passes exactly through the corners. A circle uses the straight-line distance to the farthest corner instead, which for the same box is about 112 pixels.

A few honest limits. The colours blend in the sRGB colour space by default, which is why blue to yellow goes through a greyish middle; modern CSS lets you write "in oklch" to blend differently, and this tool does not add that for you. A mesh made of radial layers is an approximation of the meshes drawn in design apps, which bend colour along curves; it gives the soft, cloudy look, not exact control of every point. And very large gradients with few colours can show faint banding on some screens, which a little noise over the top hides; the Pattern Generator makes that noise.

Frequently asked questions

What is the difference between linear, radial and conic?

Linear blends along a straight line at an angle. Radial blends outward from a centre point in a circle or an ellipse. Conic blends around a centre point, so the colour changes with the angle rather than the distance.

Is a mesh gradient real CSS?

CSS has no mesh gradient type. The effect is made by stacking radial gradients, each a colour that fades to transparent, on top of a base colour. Every browser that supports radial gradients draws it, which today is all of them.

Which way does the angle point?

In CSS, 0deg points up, 90deg points right, 180deg points down and 270deg points left. The gradient starts on the opposite side and ends in the direction the angle points, so 90deg runs from left to right.

Why are my stops reordered in the CSS?

Because CSS does not sort them. If a stop is placed before the one ahead of it, the browser moves it forward to that earlier position, which hides a colour. Writing them in order means the CSS draws what the preview shows.

Is anything sent to a server?

No. The CSS is written by code running on this page, and the preview is drawn by your own browser.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.