Stroke <-> Fill
Recent RSS
Creator:  ken frederick
Date:  9. January 2008, 07:33

A very simple script that will flip-flop fills into strokes and visa versa.

Specifically for a selection of items that have different colored fills/strokes, instead of selecting each individually this script takes care of it.


I've uploaded a non-Scriptographer version of this script here as well "illustrator_MultipleStrokeFillSwap.jsx" this can be used within Illustrator via File > Scripts > Other Script...

Otherwise if you're using Scriptographer still, download the original "strokefill_0_5.js"


simple script, simpler shortcut?
From:  mel
Date:  6. March 2008, 11:26

why not use the shortcut Shift+X for this? lol

Re: simple script, simpler shortcut?
From:  Jürg Lehni
Date:  6. March 2008, 13:55

Maybe because he did not know about it?

I think there are nicer ways to point out that a certain functionality is already contained in the software than this. Let's stay friendly here.

Re: simple script, simpler shortcut?
From:  ...
Date:  6. March 2008, 13:56

thats why: ....specifically for a selection of items that have different colored fills/strokes....

Re: simple script, simpler shortcut?
From:  alvin yeung
Date:  6. April 2009, 04:16

Shift + X doesn't apply to multiple objects with variant colors.

i.e: box with blue fill and black line, and box with blue fill and red line ... shift + X will not apply to all of them in a single instance,

let's you have 200 of these objects to flip, i'm sure "LOL" won't the first thing that would slip into your mind.

I haven't used this script yet but I am assuming this is the purpose; and if it is, it's super useful for so many designers and illustrator's so I don't think there's much to laugh at.

big ups to lehni for this project and frederickk for this script.

Re: simple script, simpler shortcut?
From:  pd
Date:  25. September 2013, 22:37

Has anyone gotten this to work yet? no luck for me.

Getting following error in the dialog box

TypeError: Cannot find function getMatchingItems in object Document @638d400.
at Scriptographer Scripts\stroke_-_fill_0_2-previous.js:15

Let me know

Re: simple script, simpler shortcut?
From:  pqbd
Date:  26. September 2013, 03:56

Sure it works. Have you tried the 0.4.2 version?

Re: simple script, simpler shortcut?
From:  pd
Date:  27. September 2013, 23:07

Yes i'm testing on version 0.4.2 and I'm getting no results.

Ive tested example scripts and they are working fine so java is running fine, any advice?

Re: simple script, simpler shortcut?
From:  ken frederick
Date:  28. September 2013, 10:18

I've cleaned out extraneous code, tested on CS5, and re-uploaded above as version 0.5. Let me know, if this solves your issue.


  • --

However, since this script is pretty simple, here's the code in Adobe's native ExtendScript:

// save the following code with the extension .jsx
// not debugged, but works for me
// and place it in (Mac) Adobe Illustrator CS*/Presets/en_EN/Scripts
// restart illustrator
// now it's visible under File -> Scripts
var sel = app.activeDocument.selection;

for( var i=0; i<sel.length; i++ ) {
var obj = sel[i];

// grouped
if( obj.pathItems != undefined ) {
for( var j=0; j<obj.pathItems.length; j++ ) {
swapStrokeFill( obj.pathItems[j] );
// singular
else {
swapStrokeFill( obj );

function swapStrokeFill(obj) {
var tempStrokeColor = obj.strokeColor
var tempFillColor = obj.fillColor

if(obj.strokeColor != null && obj.fillColor == null) {
obj.fillColor = tempStrokeColor;
obj.strokeColor = null;
else if(obj.strokeColor == null && obj.fillColor != null) {
obj.strokeColor = tempFillColor;
obj.fillColor = null;
else if(obj.fillColor != null && obj.strokeColor != null) {
obj.strokeColor = tempFillColor;
obj.fillColor = tempStrokeColor;

Re: simple script, simpler shortcut?
From:  Salman
Date:  20. September 2015, 14:47

Thank you, Works great

I created the file myself with your code.

08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19