CSS Gradient Generator
Build linear and radial CSS gradients with two colour stops, an angle slider and a live preview — then copy the code.
- Free forever
- No sign-up
- Runs in your browser
Start color
End color
background: linear-gradient(90deg, #6366f1, #ec4899);What is a CSS gradient generator?
A CSS gradient generator turns a couple of colour choices into the exact CSS you need to paint a smooth blend behind any element. Instead of memorising the syntax of linear-gradient() and radial-gradient(), or guessing which angle points which way, you pick your colours, drag a slider, and copy a line that is ready to paste into a stylesheet.
The tool above builds a two-stop gradient — a start colour and an end colour — and lets you switch between a linear blend along an angle and a radial blend that spreads out in a circle. A large live preview shows exactly what the gradient looks like, updating the instant you change anything, so there is no write-save-refresh loop. When you are happy, one click copies the full background: declaration.
Gradients are everywhere in modern interfaces: hero sections, buttons, cards, badges and subtle page backgrounds. Getting one right by hand means fiddling with hex codes and re-checking the angle; this generator collapses that into a few seconds.
How to use it
- Choose a gradient type with the Linear / Radial toggle. Linear shows an angle slider; radial spreads from the centre, so no angle is needed.
- Set your start colour. Use the swatch to open your system colour picker, or type a hex value like
#6366f1directly — and if you need that colour as RGB or HSL, the Color Converter translates it instantly. An invalid hex is flagged so you always know the value is being used. - Set your end colour the same way.
- Adjust the angle (linear only) by dragging the slider from 0 to 360 degrees and watch the preview rotate.
- Swap the colours with the swap button if you want to flip the direction of the blend without retyping.
- Copy the CSS with one click and paste it into your stylesheet or inline
style.
Everything runs on your own device, so the preview stays instant no matter how many tweaks you make, and it keeps working offline once the page has loaded.
Understanding the CSS it produces
The generator outputs a single declaration you can drop straight onto an element:
background: linear-gradient(90deg, #6366f1, #ec4899);
Reading it left to right: background is the property, linear-gradient() is the function, 90deg is the direction, and the two hex values are the colour stops. Switch to radial and the function becomes radial-gradient(circle, …), which blends outward from the middle instead of along a line.
Because the value lives on the standard background property, it works in every modern browser and on almost any element — a div, a button, a section, even text when paired with background-clip techniques. You can also assign it to background-image if you want to layer it over a solid background-color.
Linear vs radial: when to use each
- Linear gradients are the workhorse. They suit page headers, call-to-action buttons, progress bars and any surface where you want a sense of direction or motion. The angle is your main control: low angles feel horizontal and calm, diagonal angles feel more dynamic.
- Radial gradients create a focal point. They are ideal for spotlights behind a logo, soft vignettes, glowing badges and backgrounds that should feel like light is coming from one spot. Because they radiate from the centre, they draw the eye inward.
A quick rule of thumb: if you want the design to lead somewhere, reach for linear; if you want it to centre attention, reach for radial.
Tips for gradients that look good
- Keep the two colours related. Hues that sit near each other on the colour wheel blend cleanly — the Color Palette Generator is a quick way to find a harmonious pair. Colours from opposite sides can produce a muddy band in the middle where they meet.
- Mind the contrast for text. If text sits on top of the gradient, check that it stays readable across the whole range, not just at one end. A subtle gradient is usually safer than a dramatic one behind copy.
- Use angle to set mood. A near-horizontal sweep feels steady; a 45-degree diagonal feels energetic. Small angle changes can noticeably shift the feel.
- Try swapping. The swap button flips start and end instantly — sometimes the reversed direction simply reads better, and it costs nothing to compare.
- Subtle wins for backgrounds. For large page backgrounds, two close shades of the same colour often look more refined than a bold two-hue blend.
Private, instant and always free
Because this gradient generator runs entirely in your browser, there are no accounts, no limits and nothing leaves your device. Keep it open while you design — pick, preview, copy, paste — and turn a vague idea for a background into clean, working CSS in seconds, with your colours staying yours.
Frequently asked questions
Comet's got your back
Stuck on something? Every tool has a short guide and FAQ — and Comet can point you to the right spot.
Visit help centreRelated tools
All Color tools →Color Converter
Convert any color between HEX, RGB and HSL instantly — pick, preview and copy in one place.
ColorColor Contrast Checker
Check text-vs-background contrast against WCAG AA & AAA — with a live preview.
ColorImage Color Palette Extractor
Pull the dominant color palette out of any image — right in your browser.
Color