Selection to Gradient Swatch
Script for Adobe Illustrator
✦ Available exclusively on Patreon for Pro supporters.
ㅤ
Description
Selection to Gradient Swatch is a powerful tool that analyzes your selected objects in Adobe Illustrator and automatically generates a gradient swatch based on the colors found. The script offers extensive customization options including:
- Extract colors from fills, strokes, or both
- Control the order in which colors are extracted (top-to-bottom, left-to-right, randomized, etc.)
- Remove duplicate colors for cleaner gradients
- Reverse gradient direction
- Choose between linear or radial gradient types
- Live preview of the gradient before creation
- Support for RGB, CMYK, Grayscale, and Spot colors
ㅤ
Installation
1. Download the Selection to Gradient Swatch.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. Alternatively, run it directly via File > Scripts > Other Script... and browse to the file location; or just drag and drop the Selection to Gradient Swatch.jsx file onto your Illustrator document window.
ㅤ
Using the Script
ㅤ
Select Your Objects
Select one or more objects in your Illustrator document that contain the colors you want to extract. The script works with:
- Paths with fill colors
- Paths with stroke colors
- Text frames
- Groups
- Compound paths
Note: Make sure your selected objects have visible fill or stroke colors applied.
ㅤ

Run the Script
- Go to File > Scripts > Selection to Gradient Swatch
- The script dialog will open with a live preview of your gradient:
ㅤ

ㅤ
➊ Choose Color Source
Select which colors to extract from your selection:
- Fill Colors Only: Extract only fill colors from selected objects
- Stroke Colors Only: Extract only stroke colors from selected objects
- Both Fill and Stroke Colors: Extract colors from both fills and strokes
➋ Adjust Preview Options
Fine-tune your gradient with these options:
- Combine identical colors: Remove duplicate colors from the gradient (checked by default)
- Reverse: Flip the gradient direction horizontally
The preview panel shows a real-time visualization of your gradient as you adjust settings.
➌ Set Gradient Type
Choose the gradient style:
- Linear: Creates a straight gradient transition
- Radial: Creates a circular gradient transition
➍ Name Your Gradient
Enter a custom name for your gradient swatch, or leave it blank to auto-generate a name based on your settings (e.g., "Gradient").
If a gradient with the same name already exists, the script will automatically append a number to make it unique.
➎ Configure Extraction Order
Choose how colors should be ordered in the gradient:
- Top → Bottom, Left → Right: Colors are extracted row by row, from top to bottom
- Left → Right, Top → Bottom: Colors are extracted column by column, from left to right
- Bottom → Top, Right → Left: Colors are extracted in reverse row order
- Right → Left, Bottom → Top: Colors are extracted in reverse column order
- Randomized: Colors are shuffled randomly (use the ✚ button to re-shuffle)
➏ Create the Gradient
- Click OK to create the gradient swatch
- Click Cancel to close the dialog without creating a gradient
The new gradient will be added to your Swatches panel and is ready to use!
ㅤ

ㅤ
Tips & Tricks
- Color Palette to Gradient: Select multiple color swatches or objects arranged in your desired order to create a custom gradient
- Artwork Sampling: Select artwork with interesting color combinations to extract a gradient that matches your design
- Randomize for Variety: Use the Randomized order option and shuffle button to explore different color arrangements
- Text Colors: The script can extract colors from text frames, making it easy to create gradients from typography
- Spot Color Support: The script handles Spot colors and Global swatches, converting them appropriately for gradient use
☻ Wrap-up:
With Selection to Gradient Swatch, transforming your artwork's colors into custom gradients is just a few clicks away.
Experiment with different extraction orders, combine or separate colors, and preview your results in real-time before adding them to your Swatches panel.
Whether you're building cohesive color schemes or exploring creative color transitions, this script streamlines the process and puts full control in your hands.
ㅤ
ㅤ