CSS Gradient Generator
Build linear, radial and conic CSS gradients with 2–16 color stops, opacity, repeating patterns and live preview. Copy CSS or save reusable settings locally.
Color stops
Preview
Build a gradient you can reuse
Choose a preset or edit each HEX color, opacity and percentage position. The preview and CSS update as you type. Copy CSS into your stylesheet and replace .gradient with your own selector. Copy JSON or Save settings preserves all controls; Load settings accepts the JSON exported here.
Add stop inserts into the largest gap, including the outer edges, and copies a neighboring color. Swap previous / next exchanges colors and opacity while keeping position anchors. Sorting changes row order. Reverse mirrors the effective stop positions around 50% and reverses the color sequence; directional OkLCh hue paths are exchanged.
Choose the right geometry
Linear blends along a line: 0° points up, 90° right, 180° down and 270° left. The line depends on the element dimensions, so diagonal gradients can look different on a tall panel.
Radial spreads outward from Center X / Y. Choose circle or ellipse and the side or corner used to size it. Conic turns clockwise around the center; positions use percentages of a full turn, so 25% is 90°. Match the first and last colors to hide the seam.
Stops, hard edges and repeating patterns
Equal positions create a hard edge, useful for stripes. A later position below an earlier one is moved forward by CSS rather than sorted; the tool warns without changing your code. The Stripes preset demonstrates two hard edges.
Repeating uses the span from the first effective position to the last as one period. Use distinct endpoints: zero periods have browser differences (the tested Chromium uses the final color), and tiny periods may become uniform. This editor supports explicit 0–100% positions; it does not accept pixel stops, out-of-range stops or transition hints.
Color interpolation and transparent overlays
HEX inputs specify sRGB colors. Compatible mode uses legacy HEX / rgba() stops. Linear-light sRGB, Oklab and OkLCh change the blend between those stops; OkLCh also offers four hue routes. These choices do not turn the input colors into wide-gamut source colors.
Modern modes export a compatible declaration followed by the requested declaration. Browsers that reject the latter keep the former. Native CSS performs alpha interpolation. Try a transparent stop against white and black to judge an overlay; the checkerboard and preview shape are never included in exported CSS.
Limits, privacy and accessible use
The editor accepts 2–16 stops, 3/6-digit HEX, opacity and positions from 0–100, and up to three decimal places. Angles from −36000 to 36000 normalize to one turn. Import is limited to 32 KiB and validates the whole settings object before applying it. A failed import keeps the current gradient.
All gradient processing and settings imports run locally in your browser; this tool does not upload them or store them in local storage. Sliders support arrow keys, and every value has a labeled text control. Decorative backgrounds need readable foreground text: check contrast across the entire gradient and on the final page. A conic background used for a chart still needs accessible data or text.
Related resources
Questions & answers
Why does 0° point up instead of right?
CSS linear gradients start their angle at the top and turn clockwise. This differs from some drawing APIs. Use 90° for a left-to-right blend.
Can I create a transparent gradient?
Yes. Set a stop’s opacity below 100%. The generated rgba() color retains its HEX RGB channels. Choose a preview background to inspect it; that background is not exported.
Why do my repeated colors form a solid block?
Check the first and last effective positions. Equal endpoints give a zero repeating period, whose output differs between browsers; the tested Chromium uses the final color. Spread the endpoints apart. Very small periods can also be too fine for a screen to resolve.
Is the CSS a picture or an API response?
It is native CSS background-image code. The page is static, and editing runs in the browser. No image upload or API call is needed; the JSON download stores editable settings, not an image.
Other Languages
References
How we make sure
We check this tool with the automated test suites linked below. Example checks are shown in their original language.
- Verification method
- Compare actual generation/parsing results with explicit expected values, checking gradient CSS, color positions and numeric precision bounds.
- Comparison reference
- Authored CSS/parameter fixtures and boundary assertions; no second CSS layout engine.
- Verification scope
- These checks validate output/calculation rules, not rendering equivalence across all browsers.
Test source and cases (select a file to read it)
-
gradient-tools.test.js
- gradient: exact independent legacy CSS and canonical settings without mutation
- gradient: bounded decimal parser rejects coercion, unsupported notation and excessive precision
These checks cover the listed examples and boundaries, not every possible input. Round trips and checks using the same library are not independent verification.