Selection to HEX
Script for Adobe Illustrator
✦ Available exclusively on Patreon for Pro supporters.
ㅤ
Description
Selection to HEX scans your selected Illustrator objects and extracts all unique color values, converting them to HEX format. The script handles multiple color types (RGB, CMYK, Grayscale, Spot colors) and can extract colors from fills, strokes, text characters, and gradient stops.
The intuitive dialog interface displays extracted colors as interactive swatches with toggle checkboxes, allowing you to selectively include or exclude specific colors before copying the final HEX codes to your clipboard.
ㅤ
Installation
1. Download the Selection to HEX.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 > Selection to HEX
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
ㅤ
ㅤ
Select Objects
In your Illustrator document, select the objects containing the colors you want to extract. You can select:
- Single or multiple shapes
- Text objects
- Groups
- Compound paths
- Objects with gradients
ㅤ

ㅤ
Run the Script
- Navigate to File > Scripts > Selection to HEX (if installed)
- Or use File > Scripts > Other Script to browse and run the file
- The script dialog window will appear with multiple options:

ㅤ
➊ Configure Extraction Options
In the dialog window, choose which color sources to extract from:
- Fill – Extract colors from object fill colors
- Stroke – Extract colors from object stroke colors
- Text – Extract colors from text fills and strokes (including individual character colors)
- Gradient – Extract individual color stops from gradient fills
ㅤ
Enable or disable options by checking/unchecking the corresponding checkboxes. The results update automatically.
ㅤ
ㅤ
➋ Extracted HEX Colors
The Extracted HEX Colors panel is a multiline text field that lists every enabled color as a #RRGGBB code, one per line. It is your ready-to-use output — the exact text that gets copied to the clipboard when you click Save.
The contents of this field update in real time: enabling or disabling a color swatch instantly adds or removes the corresponding code. You can also select and copy text from this field manually if you only need a subset of the codes.
ㅤ
ㅤ
➌ Preview Extracted Colors
The Unique Colors Found panel is a scrollable list that gives you a visual overview of every distinct color extracted from your selection. The panel title shows the current count of enabled colors. Each row in the list represents one color and contains four interactive elements:
- A checkbox — toggles the color on or off. Disabling a color removes it from the Extracted HEX Colors field without deleting it from the list, so you can re-enable it at any time.
- A color swatch — a filled rectangle painted in the actual color, giving you an immediate visual reference. The swatch appears faded when the color is disabled.
- An editable HEX field — displays the #RRGGBB code for that color. The field is disabled while the color is toggled off.
- A zoom button (✚) — selects all objects in your document that use this color and fits them into the canvas view, letting you instantly locate where a specific color is used in your artwork.
ㅤ
Toggle Individual Colors
Click the checkboxes next to any color swatch to enable or disable specific colors. Disabled colors will be removed from the HEX codes list and appear faded in the preview.
ㅤ
Zoom to Color
Click the ✚ button next to any color swatch to instantly zoom to all objects using that color. The script will select those items and fit them into the document window, making it easy to locate where a specific color is used.
ㅤ
ㅤ
➍ Copy to Clipboard
Click the Save button to copy all enabled HEX codes to your system clipboard. You'll see a confirmation message when complete.
Click Close or press Esc to exit the script.
ㅤ
The script automatically converts the following Illustrator color types to HEX:
- RGB Colors — Direct conversion to HEX
- CMYK Colors — Converted using Illustrator's color conversion engine
- Grayscale Colors — Converted to equivalent RGB values
- Spot Colors — Converted using the underlying color definition
-
Gradient Stops — Each stop extracted as a separate colorㅤ
ㅤ
ㅤ
☻ Wrap Up
Selection to HEX streamlines your color workflow by eliminating manual color sampling and conversion.
Whether you're documenting brand colors, building a style guide, or transferring palettes between tools, this script saves time and ensures accuracy. Select your artwork, run the script, and your HEX codes are ready to use.
ㅤ
ㅤ