HEX to Swatches
Script for Adobe Illustrator
✦ Available exclusively on Patreon for Pro supporters.
ㅤ
Description
HEX to Swatches is a powerful and intuitive Adobe Illustrator script that streamlines your color workflow. Paste any list of HEX color codes — from raw text, #HEX notation, or even a Coolors.co palette URL — and instantly generate a named swatch group or a smooth gradient. The interactive preview lets you tweak colors, reorder them, assign custom names, and selectively include or exclude specific swatches before committing anything to your document. Settings are persisted between sessions so the script picks up right where you left off.
ㅤ
Installation
1. Download the HEX to Swatches.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 > HEX to Swatches
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
ㅤ
Launching the Script
- Open Adobe Illustrator and ensure you have an active document open.
- Go to File › Scripts › Other Script… (or use your preferred script launcher such as ScriptBox).
- Locate and select HEX to Swatches.jsx to run it.
- The script dialog will appear with multiple options:
ㅤ

ㅤ
ㅤ
➊ Paste HEX List
Inputting Colors
Paste or type your color data into the multiline text field. The parser is intentionally flexible and can extract HEX codes from any of the following formats:
- plain #RRGGBB or short #RGB
- plain RRGGBB or RGB
- 0xRRGGBB notation
- comma-, space-, or newline-separated lists
- raw text containing embedded HEX codes
- Coolors.co palette or similar URLs
ㅤ
Examples:
- #FF5733, #f57
- FF5733, abc
- 0xFF5733
- #FF5733, #C70039 #900C3F
- Color is ff5733 for the header
- https://coolors.co/palette/ff5733-c70039-900c3f
ㅤ


ㅤ
Short HEX codes are automatically expanded:
- 1 digit → repeated 6 times (f → ffffff)
- 2 digits → repeated 3 times (f0 → f0f0f0)
- 3 digits → each digit doubled (f01 → ff0011)
- 8 digits (RGBA) → alpha channel stripped (ff001180 → ff0011)
ㅤ
Duplicate colors are automatically removed — the Unique Colors Found counter reflects the deduplicated count.
ㅤ
Toolbar buttons:
- Refresh (✚): cleans and reformats the input so each valid color appears on its own line.
- Clear (✖): removes all input text.
Note: Both buttons are disabled when the input field is empty.
ㅤ
ㅤ
➋ Swatches Preview
Managing Colors
Every valid color appears as an interactive row in the preview list. Long palettes automatically get a scrollbar.
ㅤ

ㅤ
Each row includes:
- Color swatch square: click to open the native Illustrator color picker and modify the color on the fly.
- HEX field: displays the current #RRGGBB value; edit it directly to change the color.
- Name field: optional custom name; if filled, this name is used for the swatch instead of the default #RRGGBB label.
- ⏶ / ⏷ arrows: reorder the color up or down in the list; the Gradient Preview updates immediately.
- Checkbox: include or exclude the color from the final output; excluded colors are visually dimmed.
Tip: The dialog is resizable — drag the edges to make the preview panel taller when working with large palettes.
ㅤ
ㅤ
➌ Gradient Preview Panel
When Gradient mode is selected, a live Gradient Preview strip appears below the Swatches Preview. It renders a pixel-precise interpolation of all enabled colors and updates in real time as you add, remove, reorder, or toggle colors.
ㅤ
ㅤ

ㅤ
ㅤ
➍ Swatch Settings
Configuring Output
ㅤ
Save as
Choose one:
- Swatches: generates individual color swatches collected in a named swatch group in the Swatches panel.
- Gradient: blends the selected colors into a single named gradient in the Swatches panel. Requires at least 2 enabled colors.
ㅤ
Color Type (Swatches mode)
Choose one:
- Standard: creates standard CMYK / RGB process colors matching the document color space.
- Global: creates global spot colors — editing the swatch later updates all linked artwork automatically.
ㅤ
Gradient Type (Gradient mode)
Choose one:
- Linear: creates a linear gradient from the first to the last color, with intermediate stops evenly distributed.
- Radial: creates a radial gradient with the same stop distribution.
ㅤ
Group Name / Gradient Name
Enter a name for the new Swatch Group or Gradient. The field is required — the script will warn you if it is left empty. If a gradient with the same name already exists, a numeric suffix is appended automatically (e.g. My Palette 2).
ㅤ
Add to Canvas
When checked, the script also draws the output directly onto your active artboard:
- Swatches mode — draws a row of 50 × 50 pt squares, one per color, centered on the active artboard view, grouped under the chosen name.
- Gradient mode — draws a 200 × 50 pt rectangle filled with the new gradient, centered on the active artboard view.
The script automatically targets a visible, unlocked layer. If no editable layer exists, a new one named Hex Swatches Output is created.
ㅤ
ㅤ
➎ Running the Script
- Click OK (or press Enter) — the script creates the swatches or gradient, shows a confirmation alert, and closes.
- Click Cancel (or press Esc) — the script closes without making any changes to the document.
ㅤ
ㅤ
☻ Wrap-up:
HEX to Swatches bridges the gap between external color inspiration and your Adobe Illustrator workspace, eliminating the tedious effort of manual color entry.
Flexible smart parsing, live interactive previews, persistent settings, and versatile output options — individual swatches or multi-stop gradients, standard or global colors, panel-only or drawn directly to canvas — make it an essential tool for a faster, more organized color workflow.
ㅤ
ㅤ