GamutDesk Logo
GamutDesk

SVG Gradient Generator (linearGradient & radialGradient)

Generate SVG <defs> markup with linearGradient or radialGradient, multiple stops and angle control. Preview live and copy clean, valid SVG code.

Client-Side ArchitecturePrivate Client-Side Processing

Preview

Gradient

Type
90deg

Stops (offset %)

SVG markup
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="240" viewBox="0 0 400 240">
  <defs>
    <linearGradient id="brand-gradient" x1="0%" y1="50%" x2="100%" y2="50%">
      <stop offset="0%" stop-color="#2563EB" />
      <stop offset="100%" stop-color="#10B981" />
    </linearGradient>
  </defs>
  <rect width="400" height="240" fill="url(#brand-gradient)" />
</svg>

Technical Specification & Mathematical Principles

How the SVG Gradient Generator Works

SVG gradients are defined inside <defs> and referenced with fill="url(#id)". A <linearGradient> uses x1, y1, x2 and y2 to define the vector along which stops are interpolated. This tool converts a CSS angle (0 degrees = to top, clockwise) into that vector on the object bounding box: dx = cos(angle - 90) / 2 and dy = sin(angle - 90) / 2, centered at 50% 50%.

A <radialGradient> uses cx, cy and r for the center and radius. Each <stop> has an offset and a stop-color. Because the markup is vector data, it is resolution independent and can be inlined in HTML, saved as a .svg file or used in a CSS data URI.

Frequently Asked Questions

Why use SVG gradients instead of CSS gradients?
SVG gradients can fill strokes and text inside an SVG, can be reused through a shared id and work in standalone .svg assets, icons and exported illustrations where CSS is unavailable.
Why must gradient ids be unique?
If two inline SVGs on one page use the same id, the first definition wins for both. Give each gradient a distinct id.
How do I add opacity to a stop?
Add a stop-opacity attribute from 0 to 1 to the <stop> element. Edit the generated markup, as SVG applies it independently of the color.

Related Design & Color Instruments