Adobe Illustrator supports JavaScript scripting to automate repetitive design tasks without developing a complete plugin.

In this tutorial, we will create a simple script that automatically generates a row of five colored vector squares.

Requirements

  • Adobe Illustrator.
  • A text editor such as Visual Studio Code.

The JavaScript code

Create a file named create-shapes.jsx and insert the following code:

var doc = app.documents.add(
    DocumentColorSpace.RGB, 600, 300
);

var SIZE = 80;
var GAP = 20;
var COUNT = 5;

for (var i = 0; i < COUNT; i++) {
    var square = doc.pathItems.rectangle(
        200, 60 + i * (SIZE + GAP), SIZE, SIZE
    );

    var color = new RGBColor();
    color.red = 50 + i * 40;
    color.green = 100;
    color.blue = 200 - i * 30;

    square.filled = true;
    square.fillColor = color;
    square.stroked = false;
}

alert("Vector shapes created successfully.");

The script creates a new RGB document and generates vector squares using the pathItems.rectangle() method.

Change SIZE, GAP and COUNT to customize the layout.

Installation and usage

  1. Save the code as create-shapes.jsx.
  2. Launch Adobe Illustrator.
  3. Select File → Scripts → Other Script.
  4. Select the script and run it.
  5. Check the generated vector artwork.

No plugin installation is required.

Expected results

Property Result
Document size 600 × 300 pt
Vector shapes 5 squares
Square size 80 × 80 pt
Spacing 20 pt
Fill Different RGB colors
Stroke None

Each square remains fully editable in Illustrator.

The script has been successfully tested in Adobe Illustrator.

Conclusion

JavaScript scripting allows developers to automate vector artwork creation in Adobe Illustrator with just a few lines of code.

This example provides a starting point for generating layouts, patterns and other repetitive design elements.

Learn more

Official Adobe documentation: