How to Add a Gradient Fill to Any SVG
- Paste your SVG code — copy the SVG markup from your icon library or design tool and paste it into the text area above. You can also click "Load SVG Example" to try with a sample icon.
- Configure the gradient — pick your gradient colors, choose between linear or radial gradient type, and adjust the angle using the slider.
- Generate and export — click "Generate SVG Gradient" to preview the result. Then copy the SVG code or download it as a file, ready to use in your project.
How SVG Gradient Fills Work
SVG gradients are defined inside a <defs> block using <linearGradient> or <radialGradient> elements. Each gradient contains <stop> elements that define the colors and their positions along the gradient. The gradient is then referenced by shapes using fill="url(#gradientId)".
Unlike CSS gradients, SVG gradients are part of the SVG markup itself. This means the gradient travels with the file — it works in image tags, as favicons, in emails, and anywhere SVGs are used. This converter handles the transformation automatically, injecting the gradient definition and updating all fill attributes in your SVG.
Linear vs Radial SVG Gradients
Linear gradients transition colors along a straight line. The angle controls the direction — 0° goes bottom to top, 90° goes left to right, 180° goes top to bottom. Linear gradients work best for icons, buttons, and UI elements where you want a clear directional color flow.
Radial gradients transition colors outward from a center point in a circular or elliptical pattern. They create a spotlight or glowing effect and work well for badges, avatars, and decorative elements. Use the gradient type dropdown above to switch between them.
Frequently Asked Questions
- How do I add a gradient to an SVG?
- Add a
<linearGradient>or<radialGradient>element inside<defs>, give it an ID, and setfill="url(#yourId)"on the paths you want to color. This tool automates the entire process — just paste your SVG and pick your colors. - What is the difference between SVG fill and CSS gradient?
- SVG fill gradients are embedded directly in the SVG markup and render as part of the image. CSS gradients are applied via stylesheets and only work in browsers. SVG gradients are portable — they work in image tags, emails, and design tools — while CSS gradients only work where CSS is supported.
- Can I animate SVG gradients?
- Yes. You can animate SVG gradient stops using
<animate>elements inside the gradient definition, or use CSS animations to transition the gradient attributes. SMIL animations work natively in SVG, while CSS or JavaScript animations offer more control. - What SVG formats does this tool support?
- This tool accepts any valid SVG markup. It parses the SVG structure, injects a gradient definition into the
<defs>section, and replaces existing fill attributes on all paths and shapes. The output is a clean, standards-compliant SVG file.