Skip to content

CSS Gradient Code Converter

Convert CSS gradients to Tailwind, SVG, SwiftUI, Android XML, Flutter and prefixed CSS. Includes HEX, RGB and HSL values. Free and no signup..

  • 100% free
  • No Signup
  • Runs in your browser

CSS gradient input

Quick examples
Live preview

Color stops in every format

Every color stop converted to HEX, RGB and HSL. Click a value to copy it.

#ColorHEXRGBHSLPosition
ADVERTISEMENT
Demo Ad 728 x 90 320 x 100

How to convert a CSS gradient

  1. 1

    Paste your CSS

    Drop in a linear, radial or conic gradient, with or without the background property.

  2. 2

    Pick a target

    Switch between CSS, Tailwind, SVG, SwiftUI, Android XML, Flutter and prefixed CSS.

  3. 3

    Copy the code

    Check the live preview, choose HEX, RGB or HSL, and copy the result.

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.

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.

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.

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.

  1. Paste your gradient: Enter a linear, radial or conic gradient, or choose one of the quick examples to see how it works.
  2. Check the live preview: The preview shows exactly how the browser draws your gradient, including transparency over a checkerboard background.
  3. Choose the output format: Open the CSS, Prefixed CSS, Tailwind, SVG, SwiftUI, Android or Flutter tab.
  4. 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.
  5. 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 top0degbg-gradient-to-t90.bottom to .top
to top right45degbg-gradient-to-tr45.bottomLeading to .topTrailing
to right90degbg-gradient-to-r0.leading to .trailing
to bottom right135degbg-gradient-to-br315.topLeading to .bottomTrailing
to bottom180degbg-gradient-to-b270.top to .bottom
to bottom left225degbg-gradient-to-bl225.topTrailing to .bottomLeading
to left270degbg-gradient-to-l180.trailing to .leading
to top left315degbg-gradient-to-tl135.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.

CSS to Flutter Gradient: LinearGradient, RadialGradient and SweepGradient

Flutter describes gradients with Dart classes. A CSS linear gradient becomes a LinearGradient with begin and end alignments, a radial gradient becomes a RadialGradient, and a conic gradient becomes a SweepGradient. Alignment values run from -1 to 1, with 0, 0 at the center, so they differ from CSS percentages. Flutter colors are written as 0xAARRGGBB, which puts the alpha pair first.

CSS to SwiftUI Gradient for iOS and macOS

SwiftUI offers LinearGradient, RadialGradient and AngularGradient. Points are expressed as UnitPoint values from 0 to 1, and each stop has a location in the same range. SwiftUI radial gradients use start and end radius values in points, so check the radius against the real size of your view. Angular gradients also measure from a different starting direction than CSS conic gradients, so compare the rotation in your preview and adjust the angle if needed.

CSS to Android Gradient Drawable XML

The Android output is a shape drawable that you can save in the res/drawable folder and set as a view background. In shape drawable XML, a linear gradient angle must be a multiple of 45, and 0 degrees runs from left to right, while CSS 0deg runs from bottom to top.

CSS to Android gradient angle conversion
CSS angleAndroid angleVisual direction
0deg90Bottom to top
45deg45Toward the top right
90deg0Left to right
135deg315Toward the bottom right
180deg270Top to bottom
270deg180Right to left

Shape drawables handle stop lists differently across Android versions, so test gradients with several colors on the oldest version your app supports. For Jetpack Compose, you can reuse the color values with the Compose Brush API, but this tool outputs XML rather than Compose code.

HEX With Alpha: CSS vs Android and Flutter

Transparent colors are a common source of bugs when moving a gradient between platforms. CSS 8 digit HEX is written as RRGGBBAA, while Android and Flutter use AARRGGBB. Half transparent red is #FF000080 in CSS, #80FF0000 in Android and 0x80FF0000 in Flutter. If a converted overlay suddenly turns a strange color, check the position of the alpha pair first.

Gradient Code Conversion Errors and How to Fix Them

  • Not recognized as a gradient: Paste a standard linear, radial or conic gradient, including the repeating forms. Vendor prefixed syntax is not accepted as input.
  • Missing parenthesis: Make sure that every color function and the gradient itself are closed.
  • Only one color: A gradient needs at least two color stops.
  • Several layered backgrounds: Only the first gradient layer is converted, so paste other layers one at a time.
  • CSS variables in the code: Replace var() references with real color values before converting.
  • Different look on a device: Platforms size radial and conic gradients in their own ways, so compare the result with the CSS preview.

Related Gradient and Color Tools

Want to design a gradient visually before converting it? Start in the CSS Gradient Generator. To collect colors, use the Palette Generator or the Image Color Picker, and check text placed over a gradient with the Contrast Checker.

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.

ADVERTISEMENT
Demo Ad 300 x 250 300 x 250
COMMON QUESTIONS

CSS Gradient Code Converter FAQ

Quick answers about converting CSS gradients to Tailwind, SVG, SwiftUI, Android XML and Flutter.

How do I convert a CSS gradient to Tailwind CSS?

Paste your CSS gradient into the converter and open the Tailwind tab. You get an arbitrary-value class that works in every Tailwind version, and when the gradient has up to three standard stops you also get the from, via and to utility classes.

Can I convert a CSS gradient to SVG, SwiftUI, Android XML or Flutter?

Yes. The converter generates an SVG gradient snippet, SwiftUI gradient code, an Android XML shape drawable and a Flutter gradient from the same CSS input. Linear and radial gradients are supported everywhere they exist, and conic gradients convert to SwiftUI, Android and Flutter.

Do I still need -webkit- prefixes for CSS gradients?

Almost never. All current major browsers support the standard gradient functions without prefixes. The Prefixed CSS tab is provided for projects that must support very old browsers, and it includes a solid-color fallback and the standard rule last.

How are CSS gradient angles converted for Android and SwiftUI?

CSS angles start at the top and grow clockwise, so the converter maps them to the gradient direction each platform expects. For Android it converts to the counterclockwise angle system and rounds to the nearest 45 degrees, and for SwiftUI it calculates start and end points from the angle.

Will the converted gradient look exactly the same everywhere?

Very close, but not always identical. Platforms handle shape sizes, corner angles and radial extents differently, and Android only supports 45 degree steps. Always check the result in the target environment, especially for non-square shapes and radial gradients with custom sizes.

Which gradient code can I paste into the converter?

You can paste linear, radial and conic gradients, including repeating versions, with HEX, RGB, HSL or named colors, alpha transparency and any number of stops. Paste the standard unprefixed syntax. If you include several gradient layers, the first one is converted.

Is my gradient code uploaded or saved anywhere?

No. The conversion happens entirely in your browser, and nothing is sent to or stored on our servers. You do not need an account, and no watermark is added to the code.

ADVERTISEMENT
Demo Ad 728 x 90 320 x 100