Skip to tool
ecech.
💻 Developer & Code

Free CSS Gradient Generator with Multiple Colour Stops and Copyable Code

Linear, radial and conic gradients with as many stops as you like — plus the fix for the muddy grey band that appears between complementary colours.

135°

Colour stops

The CSS


sRGB vs oklab, same two colours

Default sRGB interpolation

in oklab — keeps chroma through the middle

Advertisement

How the calculation works

Blue to yellow, two ways Two stops grey here Straight-line interpolation in sRGB passes close to the neutral axis. Chroma collapses. Three stops One mid stop pushes the path around the neutral axis. The transition stays saturated. The same effect is achieved by in oklab, which interpolates in a perceptual space instead.

How to Use This Tool

A CSS gradient is one line of code, which is why gradient generators are everywhere. What almost none of them tell you is why your gradient looks muddy in the middle — and that is the only part of this subject that is not obvious.

The grey dead zone

By default the browser interpolates between two colours by moving in a straight line through sRGB space. When the two colours sit on roughly opposite sides of that space — blue to yellow, red to green, purple to lime — the straight line passes near the neutral axis, and saturation collapses in the middle. You asked for blue to yellow and got blue, grey, yellow.

There are two fixes, and both are shown live above:

  • Add a mid stop. Insert a colour roughly a third of the way round the hue circle between the two ends, at the 50% position. This bends the path away from the neutral axis. Blue to yellow becomes blue, teal, yellow.
  • Interpolate in oklab. Modern browsers accept linear-gradient(in oklab, blue, yellow), which interpolates in a perceptually uniform space and maintains chroma through the middle without any extra stop. Support is good in current browsers but not universal, so the tool emits the plain version first and the oklab version as an optional upgrade.
Why the middle goes grey: the shortest path between opposite hues runs through the centre. neutral two stops — chord three stops — stays on the rim
Schematic, not a literal colour space. The principle holds: any path that passes near the centre loses saturation there.

The three gradient types

Linear runs along a straight line at whatever angle you set; 0deg points up and the angle increases clockwise, which catches people out because it is the opposite of the mathematical convention. Radial spreads outward from a point, which is what you want for spotlights and soft page backgrounds. Conic sweeps around a point like a clock hand, and is the only one of the three that can produce a colour wheel or a pie chart in pure CSS.

Stop positions matter more than colours

A gradient with stops at 0% and 100% is a slow, even wash. Moving the stops closer together produces a sharp transition with flat colour on either side, and placing two stops at the same position produces a hard edge with no blending at all — which is how you make stripes in CSS without images.

A performance note

Gradients are cheap to paint but not free, and animating one by changing its colour stops forces a repaint on every frame. If you need a moving gradient, animate background-position on an oversized gradient, or transform a pseudo-element instead. Both stay on the compositor and cost almost nothing.

Advertisement

Frequently Asked Questions

Why does my gradient look grey or muddy in the middle?
Because the browser interpolates in a straight line through sRGB, and between colours on opposite sides of that space the line passes close to neutral grey. Blue to yellow and red to green are the classic cases. Fix it by adding a mid stop about a third of the way round the hue circle, or by using 'in oklab' so the browser interpolates in a perceptual space instead.
What does 'in oklab' do in a CSS gradient?
It tells the browser to interpolate in the Oklab colour space rather than sRGB. Oklab is designed so that equal numeric steps look like equal perceptual steps, which keeps saturation and perceived lightness sensible through the middle of a gradient. Support is good in current browsers, so keep a plain gradient as the preceding declaration for older ones.
Which way does the angle go in a linear gradient?
0deg points upward and the angle increases clockwise, so 90deg points right and 180deg points down. This is the opposite of the usual mathematical convention where angles increase anticlockwise from the positive x-axis, which is why gradients so often come out mirrored on the first attempt.
How do I make a hard edge instead of a blend?
Place two colour stops at the same position: linear-gradient(red 50%, blue 50%) gives a sharp split with no blending. Repeating this pattern is how CSS stripes, checkerboards and progress-bar hatching are made without any image files.
What is a conic gradient useful for?
Anything that sweeps around a centre point. Pie and donut charts, colour wheels, radial progress indicators, and the angled sheen on a 'shiny' card border are all conic gradients. It is the only gradient type of the three that can produce a full hue circle in one declaration.
Are CSS gradients bad for performance?
Painting one is cheap. Animating one is not, because changing colour stops forces a repaint every frame. If you want movement, apply the gradient to an oversized element and animate background-position or a transform instead — those run on the compositor and cost almost nothing.
Can I use a gradient on text?
Yes, with background-clip. Set the gradient as the element's background, then apply background-clip: text and colour: transparent. Include the -webkit- prefixed version for wider support, and always keep a solid fallback colour declared first, because if background-clip fails the text becomes invisible rather than merely unstyled.

Related tools in Developer & Code

Browse all Developer & Code tools
The Mac mini the ecech. site is built on, beside a handwritten note reading ecech.com.

Made by one person

ecech. is not a content farm. Every tool here is written and checked by hand, one at a time, by someone who wanted the tool to exist and could not find a version that showed its working.

No accounts and no sign-in, and nothing you type reaches a server — every calculation on this page runs inside your browser. The ads are served by Google and do set their own cookies, which is set out in full on the privacy page. More about the site.