Recolor Artwork: single swatch to multiple swatches

I have an Illustrator document with a lot of objects. All the objects are black, same swatch.

I have a swatch group with a few dozen coloured swatches. I wish to apply these swatches to all the many black objects. It doesn’t have to be in any particular order, but each object should be coloured individually—I don’t just want to change black into some other colour, but to dozens of other colours. What I really want to avoid is having to select each object individually and then applying a different swatch to each.

I’ve never quite managed to get my head properly around the Recolor Artwork feature in Illustrator, and I cannot for the life of me get it to do anything like this. The “New” box in the Recolor Artwork dialogue box appears to accept only one colour.

Is there some way to do this using the Recolor Artwork feature? Or using some other feature that I’m not aware of? Bonus points if there’s a way to control the order in which the colours are applied; e.g., specifying an order and then click on each object in turn to apply each swatch being ‘iterated’ through in that order.

(I would prefer to avoid having to script it, but I will if there’s no other way.)


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

This script RandomSwatchesFill.jsx does exactly that, selecting all the shapes and all the swatches:


mySelection = app.activeDocument.selection;
myDoc = app.activeDocument;
if (mySelection instanceof Array)
 selSwatches = myDoc.swatches.getSelected();

if(selSwatches.length != 0)
    for (i=0; i<mySelection.length; i++)
        if(mySelection[i].typename == "PathItem" || mySelection[i].typename == "CompoundPathItem")
            selItem = mySelection[i];
            selItem.filled = true;

            swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));

            if(selItem.typename == "PathItem")
                selItem.fillColor = selSwatches[swatchIndex].color;
                selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;


If you download it change the extension from .js to .jsx

Method 2

The script posted/linked to by Danielillo does most of what I was looking for. I used it as the basis for the following script, which asks the user for the name of the swatch group to use, and then iterates through the selected objects and the swatches in the named swatch group, applying the current colour to the current object.

(The objects I had needed to have their stroke, rather than their fill, changed, so I also changed that. To colour the fill instead of the stroke, replace strokeColor with fillColor.)

var selected = app.activeDocument.selection;
var doc = app.activeDocument;
var swatchIndex = 0;

if (selected instanceof Array) {
    title = prompt("Please enter the name of the swatch group containing the colours to apply.", "");

    if (title) {
        swatches = doc.swatchGroups.getByName(title).getAllSwatches();

        if (swatches.length != 0) {
            for (i = 0, j = selected.length; i < j; i++) {
                item = selected[i];
                if (swatchIndex >= swatches.length) swatchIndex = 0;

                if (item.typename == "CompoundPathItem") {
                    item = item.pathItems[0];

                if (item.typename == "PathItem") {
                    item.strokeColor = swatches[swatchIndex].color;

(The script does not handle exceptions, so if you type in an incorrect swatch group name, you’ll probably just get errors thrown at you.)

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x