CSS GRADIENT CONVERSION GUIDE
CSS Gradient Code Converter – Convert CSS Gradients to Tailwind, SVG, SwiftUI, Android XML and Flutter Online Free
Need to reuse a CSS gradient in another framework or platform? Our free CSS gradient code converter takes any linear-gradient, radial-gradient or conic-gradient and turns it into ready-to-paste code for Tailwind CSS, SVG, SwiftUI, Android XML, Flutter and legacy prefixed CSS. It also works as a gradient color format converter, switching every color stop between HEX, RGB and HSL, with alpha transparency supported. Paste the code from a CSS gradient generator, a design tool such as Figma, or your own stylesheet, check the live preview, pick the output tab you need and copy the result. There is nothing to install, no account to create and no watermark, and the conversion runs entirely inside your browser, so your code stays private. It is a fast way to convert a CSS gradient to Tailwind classes, a CSS gradient to an SVG gradient, or a CSS gradient to mobile app code without rebuilding it by hand.
TW
CSS Gradient to Tailwind Converter
Convert a CSS gradient to Tailwind CSS in one click. You get a universal arbitrary-value class that works in every Tailwind version, plus the from, via and to utility classes whenever your gradient fits them. It is the quickest way to move a gradient from plain CSS into a Tailwind project.
SVG
CSS Gradient to SVG Gradient
Turn a CSS linear or radial gradient into a complete SVG snippet with the correct gradient vector, offsets, stop colors and opacity. Use it for logos, icons, illustrations and any place where an SVG gradient is easier to export, animate or embed than a CSS background.
iOS
Gradients for SwiftUI, Android and Flutter
Developers building mobile apps can convert the same CSS gradient to SwiftUI code, an Android XML shape drawable or a Flutter gradient. The converter translates CSS angles into start and end points, alignments and Android angle values for you.
What Is a CSS Gradient Code Converter?
A CSS gradient code converter reads the gradient syntax you already have and rewrites it in another format. A CSS gradient describes a smooth transition between two or more colors, using functions such as linear-gradient, radial-gradient and conic-gradient. The same visual idea, however, needs very different code on other platforms. Tailwind uses utility classes, SVG uses gradient elements with offsets, SwiftUI uses start and end points, Android uses shape drawables with angles in a different direction, and Flutter uses alignments from minus one to one.
Converting between them manually means translating angles, rescaling positions, changing color notation and remembering each platform's syntax. This tool automates that work. It parses your CSS, normalizes every color stop and position, and generates matching code for each target, so you can focus on design instead of syntax.
How to Use the CSS Gradient Code Converter (Step by Step)
Converting a gradient takes only a few seconds. You can paste the full declaration, such as background: linear-gradient(...), or only the gradient function. Follow these steps to convert a CSS gradient online.
-
Paste your gradient: Enter a linear, radial or conic gradient, or choose one of the quick examples to see how it works.
-
Check the live preview: The preview shows exactly how the browser draws your gradient, including transparency over a checkerboard background.
-
Choose the output format: Open the CSS, Prefixed CSS, Tailwind, SVG, SwiftUI, Android or Flutter tab.
-
Pick a color format: On the CSS tab, switch every color between HEX, RGB and HSL. Alpha values become rgba, hsla or eight-digit HEX automatically.
-
Adjust and copy: Reverse the colors, rotate the angle by 45 degrees or clean up the code, then copy the result with one click.
Types of CSS Gradients: Linear, Radial and Conic
CSS offers three main gradient functions, and each also has a repeating version. This converter understands all of them, so you can paste whichever one your design uses.
CSS gradient types and common uses
| Gradient |
Example syntax |
How it flows |
Common uses |
| linear-gradient |
linear-gradient(135deg, #ff512f, #dd2476) |
Along a straight line at an angle |
Hero backgrounds, buttons, cards, banners |
| radial-gradient |
radial-gradient(circle at 30% 40%, #fbc2eb, #a6c1ee) |
Outward from a center point |
Glows, spotlights, vignettes, soft shadows |
| conic-gradient |
conic-gradient(from 0deg, red, yellow, lime) |
Around a center, like a color wheel |
Pie charts, color wheels, loaders, dials |
| repeating-* gradients |
repeating-linear-gradient(45deg, #eee 0 10px, #fff 10px 20px) |
The same pattern repeated |
Stripes, patterns, progress bars |
Supported Output Formats: What You Get From Each Tab
The table below summarizes every output the CSS gradient converter generates and what to keep in mind when you use it.
CSS gradient conversion targets
| Target |
What you get |
Good to know |
| CSS |
Clean, normalized gradient with every color in HEX, RGB or HSL |
Every stop gets an explicit percentage position |
| Prefixed CSS |
Solid-color fallback plus -webkit-, -moz- and -o- versions |
Only needed for very old browsers |
| Tailwind CSS |
Arbitrary-value class and from, via, to utilities |
Utilities appear when the gradient has up to three standard stops |
| SVG |
linearGradient or radialGradient with stop offsets and opacity |
SVG has no conic gradient, so conic input is explained instead |
| SwiftUI |
LinearGradient, RadialGradient or AngularGradient with stops |
Start and end points come from the CSS angle |
| Android XML |
Shape drawable with a gradient element |
Three or more stops use item elements on Android 7.0 and higher |
| Flutter |
LinearGradient, RadialGradient or SweepGradient |
Colors use the 0xAARRGGBB format |
CSS Gradient Angle and Direction Conversion Chart
Platforms measure gradient direction in different ways. In CSS, zero degrees points up and angles grow clockwise. Android starts from the left and grows counterclockwise, while SwiftUI uses named start and end points. This chart shows how the most common CSS directions translate, and the converter applies the same logic to any angle you type.
Gradient direction conversion for CSS, Tailwind, Android and SwiftUI
| CSS direction |
CSS angle |
Tailwind v3 class |
Android angle |
SwiftUI start to end |
| to top | 0deg | bg-gradient-to-t | 90 | .bottom to .top |
| to top right | 45deg | bg-gradient-to-tr | 45 | .bottomLeading to .topTrailing |
| to right | 90deg | bg-gradient-to-r | 0 | .leading to .trailing |
| to bottom right | 135deg | bg-gradient-to-br | 315 | .topLeading to .bottomTrailing |
| to bottom | 180deg | bg-gradient-to-b | 270 | .top to .bottom |
| to bottom left | 225deg | bg-gradient-to-bl | 225 | .topTrailing to .bottomLeading |
| to left | 270deg | bg-gradient-to-l | 180 | .trailing to .leading |
| to top left | 315deg | bg-gradient-to-tl | 135 | .bottomTrailing to .topLeading |
Android only supports angles in multiples of 45 degrees, so the converter rounds to the nearest supported value. Tailwind v3 utilities likewise cover the eight standard directions, while the arbitrary-value class keeps any exact angle.
CSS Gradient to Tailwind: How the Conversion Works
Tailwind CSS ships with gradient utilities for direction and color stops, but they cover only simple cases. For anything else, such as custom angles, many stops, exact positions, radial or conic gradients, Tailwind lets you write the full gradient as an arbitrary value, with underscores in place of spaces. The converter generates that class for every gradient, so you can paste it straight into your markup.
When your gradient is a standard direction with two or three evenly spaced colors, you also get the familiar from, via and to utility classes. Newer versions of Tailwind renamed the direction utilities to bg-linear-to, so the tool shows both naming styles when they apply. If you are unsure which version you use, the arbitrary-value class is the safest choice.
CSS Gradient to SVG: Offsets, Stop Colors and Opacity
SVG gradients are defined once inside a defs block and then referenced by id. The converter builds that structure for you: it calculates the x1, y1, x2 and y2 vector for a linear gradient from the CSS angle, writes every stop with an offset in percent, and converts transparency into the stop-opacity attribute. Radial gradients receive center and radius values taken from the at position of your CSS. The output is a complete SVG snippet you can paste into an HTML file, an icon or a design tool.
Keep in mind that SVG has no conic gradient, and SVG gradients measure angles against the bounding box of the shape, so very wide or very tall shapes can look slightly different from the CSS version. For pixel-perfect work, check the result visually.
HEX, RGB and HSL Colors in Gradients
Gradients accept the same color notations as the rest of CSS. The converter reads any of them, including named colors like tomato or rebeccapurple, and outputs your choice of HEX, RGB or HSL. Pick the format your project or style guide uses.
Color formats used in CSS gradients
| Format |
Opaque example |
With transparency |
Best for |
| HEX |
#ff512f |
#ff512f80 |
Compact code, design handoff, brand colors |
| RGB |
rgb(255, 81, 47) |
rgba(255, 81, 47, 0.5) |
Overlays and scripts that work with channels |
| HSL |
hsl(10, 100%, 59%) |
hsla(10, 100%, 59%, 0.5) |
Themes, tints and shades, easy manual tweaks |
Do You Still Need -webkit- and -moz- Prefixes for Gradients?
For nearly all projects today, no. Every current major browser supports the standard, unprefixed linear-gradient, radial-gradient and conic-gradient functions. Prefixed versions such as -webkit-linear-gradient only matter if you must support very old browsers. The Prefixed CSS tab is there for those cases and for legacy codebases. It outputs a solid-color fallback first, then the prefixed versions with the older angle convention converted correctly, then the standard declaration last so modern browsers use it.
Conic gradients never had prefixed versions, so for those the tab simply gives you a fallback color and the standard rule.
Why Convert CSS Gradients? Common Use Cases
Gradients are designed once and used everywhere: on the web, in apps, in icons and in presentations. A converter keeps them consistent across all of those places.
- Moving to Tailwind CSS: Convert gradients from an existing stylesheet or a CSS gradient generator into Tailwind classes during a redesign or migration.
- Web to mobile: Reuse a website's brand gradient in an iOS app with SwiftUI, an Android app with a shape drawable or a Flutter app.
- SVG logos and illustrations: Turn a CSS background gradient into an SVG gradient for logos, icons and vector artwork.
- Design handoff: Translate gradients copied from design tools into the exact code format your developers need.
- Cleaning up legacy CSS: Normalize messy gradient code, convert color formats and remove vendor prefixes you no longer need.
- Learning and teaching: See how the same gradient is expressed on every platform, which is a great way to learn gradient syntax.
- Design systems: Keep gradient tokens in one source format and generate platform-specific versions on demand.
Tips for Better CSS Gradients
A few habits make gradients look smoother and work better in production. Try them with the quick actions and the live preview.
- Choose related colors: Gradients between neighbouring hues look natural, while distant hues can pass through muddy gray in the middle.
- Add a middle stop: A third color stop gives you more control over the transition and often removes dull midpoints.
- Use hard stops for stripes: Two stops at the same position create a sharp edge instead of a blend.
- Check text contrast: Make sure text stays readable over both the lightest and darkest parts of the gradient.
- Watch for banding: Long, low-contrast gradients can show visible steps, so add slight variation or subtle noise if needed.
- Use transparency for overlays: A gradient from transparent to a dark color over an image makes captions easier to read.
- Prefer CSS over images: Gradients are resolution independent and usually lighter than a background image file.
Free CSS Gradient Converter for Any Device, With Full Privacy
This CSS gradient code converter runs in your web browser on Windows, Mac, Linux, Android, iPhone and iPad, so you do not need to install software or a code editor plugin. All parsing and conversion happens locally with JavaScript, which means your gradient code is never uploaded, logged or stored. That makes it safe for client work and unreleased designs, and it keeps the tool fast even on a slow connection.
Ready to try it? Scroll back up, paste your gradient and switch between the output tabs. If you also work with colors, explore the other free color tools on our site.