Gradient Type Switcher
Script for Adobe Illustrator
ㅤ
Description
Gradient Type Switcher converts gradient fills and strokes between linear and radial types in Adobe Illustrator. It can reverse every selected gradient, perform a one-way conversion, or randomly assign Linear or Radial to each gradient while retaining the original gradient stops, colors, opacity, midpoint settings, placement, direction, length, and radial highlight properties.
ㅤ
Features
The script provides controlled gradient conversion for individual objects and complex selections without requiring gradients to be rebuilt manually.
- Four conversion modes: Switch every gradient to its opposite type, perform either one-way conversion, or randomly assign Linear or Radial to each gradient.
- Random type assignment: Give every eligible fill and stroke an independent random gradient type while keeping the preview and final result consistent.
- Fill and stroke control: Process gradient fills, gradient strokes, or both in one operation.
- Complex selection support: Find gradient artwork inside selected groups and compound paths.
- Live preview: See the selected conversion on the canvas and update it immediately when settings change.
- View assistance: Fit the initially selected gradient artwork in the window for closer inspection.
- Distraction-free preview: Hide selection edges and bounding boxes while evaluating the result.
- Reliable cancellation: Restore the original artwork, gradient angles, view, and selection display when Preview is disabled or the dialog is canceled.
ㅤ
Installation
1. Download the Gradient Type Switcher.jsx script file.
2. Place the script in your Adobe Illustrator Scripts folder:
⮑ Mac: /Applications/Adobe Illustrator (Version)/Presets/(Language)/Scripts
⮑ Windows: C:\Program Files\Adobe\Adobe Illustrator (Version)\Presets(Language)\Scripts
3. Restart Adobe Illustrator if it's already running
4. Access the script via File > Scripts > Gradient Type Switcher
5. Alternatively, run it directly via File > Scripts > Other Script... and browse to the file location
Tip: You can also drag and drop the .jsx file directly onto the Illustrator workspace to run the script instantly – no installation needed.
ㅤ
Using the Script
ㅤ
Launch the Script
Open an Illustrator document and select one or more objects that contain gradient fills or gradient strokes. The selection may include individual paths, groups, compound paths, or a combination of supported artwork.
Launch Gradient Type Switcher using either method:
- Choose File > Scripts > Gradient Type Switcher when the script is installed in the Scripts folder.
- Choose File > Scripts > Other Script... and select Gradient Type Switcher.jsx from its saved location.
- Drag the JSX file onto the Illustrator workspace to run it without installation.
Illustrator switches to the Selection Tool and opens the Gradient Converter dialog:
ㅤ

ㅤ
ㅤ
➊ Prepare the Selection
Before choosing conversion settings, confirm that the selected artwork contains at least one gradient fill or stroke. The script searches through selected groups and compound paths and ignores paints that are not gradients.
- Select every object you want to process before launching the script.
- Gradient-filled and gradient-stroked objects may be included in the same selection.
- Solid colors, patterns, and objects without a matching gradient remain unchanged.
- Locked or hidden artwork must be made selectable before the script is launched.
ㅤ
ㅤ
➋ Choose a Conversion Mode
Use the Conversion Mode panel to decide which gradient types should change. Only one mode can be active at a time.
- Convert all gradients to the opposite type: Changes linear gradients to radial and radial gradients to linear. This is the default setting.
- Convert linear gradients to radial: Changes only linear gradients and leaves radial gradients untouched.
- Convert radial gradients to linear: Changes only radial gradients and leaves linear gradients untouched.
- Switch gradient types randomly: Independently assigns Linear or Radial to each eligible gradient fill and stroke. A gradient remains unchanged when its randomly assigned type matches its current type.
When Preview is enabled, selecting a different mode updates the artwork immediately. Choosing the random mode generates a set of random assignments that remains stable through the live preview and final application, so clicking OK preserves the result shown on the canvas.
ㅤ

ㅤ
ㅤ
➌ Choose Where to Apply the Conversion
Use the Apply To panel to control which paint attributes are processed. Fills and Strokes are both selected by default.
- Enable Fills to process gradient fills.
- Enable Strokes to process gradient strokes.
- Enable both options to process all matching gradient fills and strokes in the selection.
- Disable an option to leave that paint attribute unchanged.
If neither enabled option contains a gradient that matches the chosen conversion mode, no artwork is converted.
ㅤ
ㅤ
➍ Review the Live Preview
Preview is enabled by default and displays the current conversion directly on the canvas. Changing the conversion mode or the Fills and Strokes settings rebuilds the preview from the original artwork, helping prevent changes from accumulating across previews.
- Clear Preview to restore the selected artwork to its original state while keeping the dialog open.
- Select Preview again to apply the current settings as a new preview.
- Use the preview to compare linear and radial results before committing the conversion.
- Select Switch gradient types randomly again to generate a new random arrangement when you want another variation.
- Expect nonmatching gradients and nongradient paints to remain unchanged.
Disabling Preview also removes temporary preview swatches from the Swatches panel.
ㅤ
ㅤ
➎ Adjust the Preview View
Use the view controls to inspect the converted artwork more clearly. These controls affect how the document is displayed, not the gradient conversion itself.
- Enable Fit in Window to center and fit the gradient-bearing items from the initial selection in the active view.
- Disable Fit in Window to return to the zoom level and view position captured when the script started.
- Keep Hide Edges enabled to hide selection outlines and bounding boxes during preview. This option is enabled by default.
- Disable Hide Edges when you need to see the selected paths and bounds.
Fit in Window is unavailable when the initial selection contains no detected gradient fills or strokes.
ㅤ
ㅤ
➏ Apply the Conversion
After reviewing the preview, click OK to apply the selected settings. The script restores the clean original state first and then performs one final conversion so the committed result matches the current controls.
The completed conversion preserves the following gradient data where Illustrator supports it:
- Gradient stop colors and positions
- Stop opacity and midpoint values
- Gradient origin, direction, and length
- Radial highlight angle and highlight length
- Separate fill and stroke placement on each processed item
Afterward, a confirmation message reports how many fill gradients and stroke gradients were converted.
ㅤ
Tip: Click Cancel or close the dialog with its window close button to discard the preview and leave the artwork unchanged. The script restores the original selected artwork, including gradient angles that Illustrator cannot reliably reconstruct through basic gradient property assignments.
ㅤ
ㅤ
☻ Wrap-Up
Gradient Type Switcher provides a focused way to convert linear and radial gradients across fills, strokes, groups, and compound paths while preserving their essential appearance. Use its live preview and view controls to compare results, then apply the conversion with OK or exit safely with Cancel.
ㅤ
ㅤ