Developer tool

CSS Gradient Generator

Choose gradient type, direction and two or more color stops to generate CSS.

Runs in your browser. No upload.

Values are processed locally in this browser.

Result

—

About this tool

CSS Gradient Generator made simple.

Colors and values are validated and processed locally. Check the result in your project and test contrast for text placed over gradients.

Guide

Using CSS Gradient Generator

The CSS Gradient Generator writes one line of CSS for a linear or radial colour gradient. You pick the type, set an angle for linear gradients, and enter two or three colours as hex codes. It returns a background rule that you copy into your stylesheet. It shows no colour preview, it has no stop positions, and it cannot tell you whether text on top of the gradient will be easy to read.

How to use it

  1. Choose Linear or Radial as the gradient type.
  2. For a linear gradient, set the angle from 0 to 360 degrees. In CSS, 0 points up and the angle grows clockwise, so 90 points right and 180 points down. A radial gradient ignores the angle.
  3. Type the first and second colours as hex codes, either three digits like #f80 or six like #ff8800. The third colour is optional, and the # sign can be left out.
  4. Press Calculate, then Copy result and paste the line into your CSS. Open the page in a browser to see the real colours.

Worked examples

The starting values

You enter
Type
linear
Angle
135
Color1
#6D5EF5
Color2
#C7F36B
You get
Css
background: linear-gradient(135deg, #6D5EF5, #C7F36B);

An angle of 135 degrees runs from the top left towards the bottom right, with the first colour at the start of the line and the second at the end.

Run through the tool’s own code.

The same colours as a radial gradient

You enter
Type
radial
Angle
135
Color1
#6D5EF5
Color2
#C7F36B
You get
Css
background: radial-gradient(#6D5EF5, #C7F36B);

The angle does not appear in the output. A radial gradient is written without a shape or size, so the browser uses its own defaults, which MDN gives as an ellipse that reaches the farthest corner.

Run through the tool’s own code.

Three colours and short hex codes

You enter
Type
linear
Angle
90
Color1
#fff
Color2
#000000
Color3
#f00
You get
Css
background: linear-gradient(90deg, #FFFFFF, #000000, #FF0000);

Three-digit codes are expanded to six digits and the letters are made uppercase. The three colours are spaced evenly from left to right at 90 degrees.

Run through the tool’s own code.

A colour name is refused

You enter
Type
linear
Angle
45
Color1
red
Color2
#123456
You get
Error
First color must be a 3- or 6-digit hex color, such as #336699.

Only hex codes are accepted. Names, rgb() and hsl() values are not, and neither are eight-digit hex codes with a transparency part. An angle above 360 is also refused.

Run through the tool’s own code.

When it helps

  • Make a quick background for a hero banner, card or button without writing the syntax by hand.
  • Try two or three brand colours together and copy the rule straight into a stylesheet.
  • Learn how the angle of a linear gradient points, by changing it and reading the output.
  • Produce a starting rule that you then edit by hand to add stop positions or a custom shape.

Limits to keep in mind

  • Only hex colours of three or six digits are accepted. There are no colour names, no rgb() or hsl() values, and no transparency.
  • A gradient has two or three colours spaced evenly. There are no stop positions, no hints and no repeating or conic gradients.
  • The angle runs from 0 to 360 and is rounded to one decimal place in the output. It is used for linear gradients only.
  • The tool prints text only. It has no preview, adds no fallback colour, and does not check contrast. Test your result in a browser.

Tips

  • Add a plain background-color line yourself as a fallback, in case the gradient does not load.
  • Check text contrast against the lightest and the darkest part of the gradient, not just the middle.
  • Pick the angle by thinking of an arrow: 90 runs left to right, 180 runs top to bottom, and 0 runs bottom to top.

Sources

Common questions

About CSS Gradient Generator.

How does the angle work in a CSS linear gradient?

MDN explains that 0deg is the same as to top, and larger values turn clockwise. So 90deg goes to the right, 180deg goes down and 270deg goes to the left. The first colour sits at the start of that line and the last colour at its end.

Why is my radial gradient ignoring the angle?

A radial gradient spreads outward from a centre point, so it has no direction to rotate. The tool leaves the angle out of the radial line on purpose. If you want the centre moved or a circle instead of an ellipse, edit the CSS by hand.

Can I use colour names, rgb() or transparency?

Not in this tool. It accepts only three-digit or six-digit hex codes and shows an error for anything else. If you need a transparent colour, paste the result into your stylesheet and replace the hex code with an rgba() value yourself.

Can I add more colours or set where each one sits?

No. The tool allows up to three colours with equal spacing. CSS itself allows more colours and positions such as a colour followed by 40%, so you can add them by hand after pasting the line.

Why did my hex code change case or length?

The tool tidies every colour into six uppercase digits, so #f00 becomes #FF0000 and #6d5ef5 becomes #6D5EF5. The colour is exactly the same. It also adds the # sign if you left it out.

Does it show a preview of the gradient?

No. You get the CSS text only. Paste it into a test page or your own project to see the gradient, and look at it on more than one screen, because colours can look different between displays.

Are my colours sent to a server?

No. The page says the values are checked and processed in your browser. The tool simply builds a text string from what you type and shows it on the page.

How do I use CSS gradient generator?

Choose gradient type, direction and two or more color stops to generate CSS.

Is my data uploaded to a server?

No. This tool runs locally in your browser. Your input is not uploaded.