Selection to Gradient Swatch

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.

image gallery

Run the Script

  • Go to File > Scripts > Selection to Gradient Swatch
  • The script dialog will open with a live preview of your gradient:

image gallery

➊ 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!

image gallery

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.

Leave a comment

Selection to Gradient Swatch

Version: 1.0.1

Updated:

  • 1.0.0 – Initial release.

    Tested on MacOS:

    • Adobe Illustrator 2023 (27.0)
    • Adobe Illustrator 2024 (28.1)
    • Adobe Illustrator 2025 (29.0)
  • Supported Versions:

    • Compatible with Adobe Illustrator CS6 and later, including Adobe Illustrator CC versions.

    Operating Systems:

    • Works on both macOS and Windows platforms.
  • End User License Agreement (EULA)

    Last Updated: 21.12.2024

    This End User License Agreement (“Agreement”) is a legal agreement between you (“User” or “Licensee”) and Samolevsky.com (“Licensor”) regarding the use of the Adobe Illustrator scripts (“Software”). By downloading, installing, or using the Software, you agree to be bound by the terms of this Agreement.

    1. Grant of License

    Licensor grants the User a non-exclusive, non-transferable, and revocable license to use the Software in accordance with this Agreement.

    • Free Software: If the Software is provided for free, you may use it for personal or commercial purposes without payment, subject to the restrictions outlined in this Agreement.
    • Paid Software: If the Software is provided for a fee, you may use it only after payment has been made in full.

    2. Usage Rights

    You are permitted to:

    • Install and use the Software on devices you own or control.
    • Use the Software in your personal or commercial projects, subject to compliance with this Agreement.

    3. Restrictions

    You may NOT:

    • Reverse engineer, decompile, or otherwise attempt to discover the source code, underlying ideas, or algorithms of the Software.
    • Reuse, incorporate, or integrate any portion of the Software into any other software, product, or project, except as expressly permitted by the Licensor in writing.
    • Resell, redistribute, or share the Software, whether in its original or modified form, without prior written consent from the Licensor.
    • Claim ownership of the Software or its underlying code.
    • Use the Software in any way that violates applicable laws or regulations.

    4. Ownership

    The Software and all intellectual property rights therein remain the exclusive property of the Licensor. This Agreement does not transfer ownership of the Software or any intellectual property rights to the User.

    5. Disclaimer of Warranties

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    6. Limitation of Liability

    To the maximum extent permitted by law, Licensor shall not be liable for any damages, including but not limited to direct, indirect, incidental, special, or consequential damages, arising out of or related to the use or inability to use the Software.

    7. Termination

    This Agreement is effective until terminated. Licensor may terminate this Agreement immediately if you breach any term of this Agreement. Upon termination, you must cease all use of the Software and destroy any copies in your possession.

    8. Updates and Support

    Licensor is not obligated to provide updates, support, or maintenance for the Software. However, updates may be provided at the sole discretion of the Licensor.

    9. Governing Law

    This Agreement shall be governed by and construed in accordance with the laws of the State of New York, without regard to its conflict of law principles.

    10. Entire Agreement

    This Agreement constitutes the entire agreement between you and the Licensor concerning the Software and supersedes all prior or contemporaneous understandings regarding such subject matter.

    By using the Software, you acknowledge that you have read this Agreement, understand it, and agree to be bound by its terms.

    For any questions or concerns regarding this Agreement, please contact us at hello@samolevsky.com

Browse More Scripts

  1. Explore Quick Rename
    Quick Rename

    Quick Rename

    Quick Rename is a powerful Adobe Illustrator script that streamlines the process of renaming selected objects in your document.

    Explore
  2. Explore Random Gradient Generator
    Random Gradient Generator

    Random Gradient Generator

    Random Gradient Generator is an Adobe Illustrator script for creating colorful linear or radial gradients with a fast visual workflow.

    Explore
  3. Explore Gradient Interpolator
    Gradient Interpolator

    Gradient Interpolator

    Gradient Interpolator is a powerful utility for Adobe Illustrator designed to eliminate banding and create perfectly fluid color transitions.

    Explore

Introducing ScriptBox

Your Complete Adobe Illustrator Productivity Hub

Required Software

Adobe Illustrator

Adobe Illustrator is a professional vector graphics software developed by Adobe Inc. It is widely used by designers, illustrators, and artists for creating a variety of digital artwork, including logos, icons, illustrations, typography, and complex design layouts. Illustrator is known for its precision and scalability, allowing users to create high-quality graphics that can be resized without losing clarity. Its features include powerful drawing tools, customizable brushes, advanced typography options, and seamless integration with other Adobe Creative Cloud applications. Illustrator is a go-to tool for creative professionals working on projects for print, web, and multimedia platforms.

  • 🅰 Locating the Scripts Folder

    To install a Selection to Gradient Swatch.jsx script in Adobe Illustrator, you need to place it in the correct directory where Illustrator
can recognize it. Follow these steps to locate the Scripts folder:

    1. MacOS:
      Open Finder and navigate to:
      Applications/Adobe Illustrator <Version>/Presets/<Language>/Scripts
    2. Windows:
      Open File Explorer and navigate to:
      C:\Program Files\Adobe\Adobe Illustrator <Version>\Presets\<Language>\Scripts
    3. Replace <Version> with your Adobe Illustrator version (e.g., 2025).
    4. Replace <Language> with your language folder (e.g., "de_DE" for German, "en_US" for English).

    🅱 Installing the Script

    1. Copy the Script File: Copy the Selection to Gradient Swatch.jsx file to the Scripts folder located in the path above.
    2. On some systems, you may need administrator permissions to modify the Scripts folder.
    3. Restart Adobe IllustratorTo refresh the scripts menu, close and reopen Adobe Illustrator.

    Explore our complete guide to mastering Adobe Illustrator scripts.

    1. Open Adobe Illustrator and ensure a document is active.
    2. Go to the top menu bar and select File > Scripts.
    3. If the script is installed in the Scripts folder, it will appear in the dropdown list.
    4. Click the Selection to Gradient Swatch script to run it.
    5. The Selection to Gradient Swatch script will execute, and any dialog boxes or results will appear based on the script’s functionality.

    ☻ Before running any scripts, it’s strongly advised to save your work — especially when working with complex or large documents.

Got questions?

Need help or have an idea to share? We’d love to hear from you! Whether you have questions, found a bug, have a feature request, or just want to share your feedback, reach out to us—we’re here for you!