Writing Scripts for Illustrator with AI
Anybody—even you—can write scripts for Illustrator with the help of AI.

This article appears in Issue 42 of CreativePro Magazine.
“There must be a faster way—somebody ought to write a script for this!”
If certain Illustrator tasks lead you to think this, you’re probably right and you can be that somebody! AI-powered tools like ChatGPT and Microsoft Copilot can help you automate repetitive processes with custom scripts—even if you’re not a coder.
As Alan Gilbertson demonstrated in Issue 35, scripting is simply a matter of breaking tasks into steps, prompting AI, and then refining the results. The same principles he used for scripting in InDesign can work in Illustrator, as you’ll see in this article. I’ll show you how to use AI to automate Illustrator tasks, from one-time fixes to daily workflows. With AI, scripting is easier than ever and a huge time-saver.
Follow Along: Grab the finished example scripts here.
Tasks You Can Automate in Illustrator
Not every task in Illustrator is worth automating, but many are! Repetitive or tedious tasks are ideal for scripting, whether they’re one-time or recurring chores. For example, you could create a quick, one-off script to delete a specific path across multiple artboards or sort hundreds of files into folders based on a naming convention. A script can handle tasks like these in seconds, saving you tons of time.
Tip: If you need to sort a large batch of files, test your script on a smaller folder of five to seven files before running it on everything. This avoids major headaches if something goes wrong.
Tasks that come up regularly in your workflow are perfect candidates for reusable scripts, for example:
- Saving or exporting files in multiple formats: If you often save your work in different formats (e.g., PDF, SVG, JPG, PNG), a script can automatically save a file in the same folder (or a specific subfolder structure) in all the required formats at once.
- Creating technical lines: Scripts can quickly generate precise technical lines, such as cut lines, crease marks, or sew-in lines, making production work more efficient and consistent.
- Sorting Items to Layers: When working with complex illustrations, a script can organize objects into layers based on their appearance attributes, such as color, stroke weight, or fill. This is particularly useful for preparing files for print or animation.
Using AI for Scripts
Writing scripts might seem tricky, but AI makes it more accessible. A paid option is OpenAI’s ChatGPT Plus, or you can use free alternatives such as Microsoft Copilot and OpenAI’s ChatGPT.
For this article, I tested ChatGPT Plus and Copilot, and included a comparison with the free version of ChatGPT for context (Table 1). While ChatGPT Plus offered useful features, Microsoft Copilot proved to be a strong free choice.

Table 1. Comparison of AI Scripting Tools
Let’s take a closer look at each, starting with the free options.
Copilot and ChatGPT code suggestions
Copilot and ChatGPT are free and easy ways to start automating tasks with AI. Copilot is an AI companion available directly in the browser, making it an accessible tool for generating Illustrator scripts. Additionally, Copilot allows you to upload images and files, making troubleshooting much easier. For example, you can upload a screenshot of an alert, and Copilot can analyze it and resolve errors effectively.
Although the free version of ChatGPT also can generate functional scripts and is a solid starting point for Illustrator automation, it has limitations. For example, you can upload a maximum of only three images for troubleshooting, which can be restrictive for more complex tasks.
While free ChatGPT works well, I found Copilot slightly better for scripting. Based on my experiments, it seems to write cleaner, more reliable code overall.
Saving and updating the free code
Once Copilot or ChatGPT provides the script, you’ll need to copy and paste the code manually into a text editor, then save it as a JSX file before running it in Illustrator.
For example, to save a CoPilot script using TextEdit (macOS), follow these steps:
- Open TextEdit.
- Choose Format > Make Plain Text (Shift+Option+T) to switch from rich text to plain text.
- Paste the script code generated by Copilot into the document.
- Save the file with a .txt extension, and select Unicode (UTF-8) to avoid errors.
- In Finder, rename the file with a .jsx extension. Confirm the change when prompted.
Here’s how to do the same thing with Notepad on Windows:
- Open Notepad.
- Paste the script code generated by Copilot into the document.
- Choose File > Save As.
- In the Save dialog box, choose All Files from the Save As Type menu, name the file with a .txt extension, and select UTF-8 for the encoding.
- In File Explorer, rename the file with a .jsx extension, and confirm the change when prompted.
Once it’s saved, you can run your script by choosing File > Scripts > Other Script in Illustrator and selecting the JSX file. If the AI provides an updated version of the code, however, be sure to replace the previous code entirely in your text editor, save the file again, and re-test it.
Generating scripts with ChatGPT Plus
For $20 per month, ChatGPT Plus offers some great features that make scripting in Illustrator even easier:
- Downloadable JSX Files: You can request JSX files that are ready to download, so you don’t have to copy and paste code manually.
- Image Uploads: Got an error while running your script? Upload a screenshot to help ChatGPT Plus troubleshoot.
- Custom Bots: You can create bots fine-tuned for Illustrator or other apps. For example, I created one specifically for Illustrator scripting. It gives me downloadable JSX files by default and shows the code only if I ask. You can check out my Script & ScrAIpt in Illustrator bot here.
Accessing Scripts from ChatGPT Plus
Using ChatGPT Plus, enter a prompt describing what you want the script to do, and then ask ChatGPT Plus to provide the script as a downloadable JSX file.
After downloading the file, follow these steps to run it in Illustrator:
- Open a test.ai file in Illustrator.
- Choose File > Scripts > Other Script.
- Locate the JSX file and double-click it.
This immediately runs the script, letting you test it before you let it loose on your main project files.
Building an Example Script: Duplicate Layer Structure
To demonstrate AI scripting, I created a script that solves a common problem through automation: duplicating a layer with its sublayer structure. That task can be tedious in Illustrator, especially when you have to rename the layer and manually remove a word copy from all its sublayers. Who has time for that?
The step-by-step instructions for the task were simple:
- Duplicate the layer and all sublayers.
- Open a dialog box where you can:
- Enter the new layer name.
- Choose to place the duplicated layer above or below the original.
Process
To test how the various AI tools handled the same task, I used a series of prompts in ChatGPT Plus (via the MyChatGPT bot) and Copilot Free. This allowed me to compare the tools’ capabilities and see how each would approach the script creation process.
I started with the prompt: I need a script for Adobe Illustrator that duplicates the active layer and all its sublayers. The script should also remove the word “copy” from the names of the duplicated sublayers. Check that an active layer is selected before running.
Both ChatGPT and Copilot generated their respective first versions of the script. And both versions of the script generated the same error message (Figure 1).

Figure 1. Error encountered during script testing
I uploaded a screenshot of the error to ChatGPT Plus and Copilot. Both tools reviewed and fixed their version of the script. And this time, both scripts worked!
Each script duplicated the active layer and all its sublayers and removed the word copy from the names.
However, I noticed that in both versions, the order of the sublayers was reversed (Figure 2). I prompted the AI tools to fix the problem: The order of the layers is reversed. Please correct this.

Figure 2. Both scripts duplicated the layer but reversed the sublayer order.
I also wanted the color of the duplicated layer and its sublayers to match, so I prompted again: Please update the script to assign a random color to the duplicated layer. All its sublayers should automatically get the same color as the main layer.
With these corrections in place (Figure 3), I added a prompt: Please add a dialog box. The dialog should include: A text field where I can enter the new layer name and two radio buttons—one for placing the new layer above the active layer and another for placing it below the active layer.

Figure 3. Sublayer order is corrected, and the layer’s color matches.
Both variant scripts opened the dialog box (Figure 4), where I could enter the layer name and choose the placement of the new layer. When I ran the updated scripts, each worked perfectly.

Figure 4. Dialog box generated by the script
Comparing ChatGPT Plus and Copilot
After testing both models, I found no significant difference in how they created scripts for Illustrator. Both generated functional and efficient code.
In one case, I needed an extra correction prompt for Copilot because it wasn’t duplicating items within the respective layers. However, this was a minor issue that could have happened with ChatGPT Plus just as easily.
Troubles and stubborn missteps
AI may misunderstand your prompts, but rephrasing or breaking them into steps often clears things up. For example, I initially used this prompt: Modify the script so that the colors of the duplicated layer and their sublayers match.
The AI misunderstood my intent, so I revised it several times. Eventually, this worked: Please update the script to assign a random color to the duplicated layer. All its sublayers should automatically get the same color as the main layer. Don’t hesitate to experiment until you find the correct wording!
AI can get stuck on a wrong idea, even after corrections. This often happens when it clings to earlier prompts. If this happens, here are two approaches to try:
- Correct the Previous Prompt: Go back and clarify or reword your earlier request. Sometimes, this is enough to get the AI back on track.
- Start a New Chat: Starting fresh often clears the AI’s “memory” of past interactions, giving you a different and often better result.
Limits
While AI tools like ChatGPT and Copilot can handle many tedious tasks, they do have limits. Some Illustrator functions that seem simple from a user’s perspective can be surprisingly complex to script. These are some of my observations based on my experience working with AI tools for scripting.
- Geometry and Coordinates: Tasks like aligning objects or calculating complex paths often require detailed corrections and trial and error.
- Advanced Features: Certain features like Offset Path or Pathfinder operations often require pre-written code that AI can adapt but not create from scratch.
- Complex Workflows: AI may fail to produce functional code without significant manual refinement for intricate, multi-step workflows.
When AI hits its limits, consider:
- Using Illustrator’s Actions for simpler tasks.
- Finding ready-made scripts online as a starting point for AI to refine. If you do this, consider making a donation to the developer for free scripts you find valuable to your work and livelihood. It’s also important to check the script’s license and, if necessary, contact the author before making edits.
- Contracting a developer: For complex tasks beyond AI’s capabilities, it can still be a cost-effective solution to pay a developer to create a tailored solution.
AI is a powerful tool, but knowing its boundaries helps you work smarter.
Deciding Time for Script Experiments
For one-time scripts, I limit myself to 20-30 minutes of script-creation time; beyond that, handling the Illustrator task manually is often faster. You can also save time by organizing your scripts with a simple system so you can easily find and reuse them if a similar task arises. I recommend that you create a dedicated folder on your computer for one-time scripts.
For more stable solutions and scripts you’ll use repeatedly, it’s worth spending more time perfecting them. A well-made script can save hours in the long run, so investing the extra effort up front often pays off.
Place the scripts you use most in Illustrator’s Scripts folder:
- macOS: Macintosh HD:Applications:Adobe Illustrator [version]:Presets:[Language]:Scripts
- Windows: C:\Program Files\Adobe\Adobe Illustrator [version]\Presets\[Language]\Scripts
Note: These are system folders, so you might need admin rights to access or modify them.
Restart Illustrator to make the script appear under File > Scripts.
Once it’s there, you can record an Action and assign a custom shortcut for even quicker access.
Alternatively, you can keep your scripts in any folder on your computer and run them via File > Scripts > Other Script, then navigate to your saved location.
Final Thoughts on AI and Scripting
AI tools make Illustrator scripting accessible. With the proper prompts, you can automate tasks, streamline workflows, and solve challenges—often, no coding expertise is needed.
Although AI has limits, knowing when to pivot to built-in tools like Actions or ready-made scripts ensures you can always find a solution. Whether creating a quick one-time script or a reusable tool, the effort you put in now can save you countless hours later.
Why not start with a small automation today? Even a simple script can save hours. Unlock Illustrator’s full potential with AI!
Commenting is easier and faster when you're logged in!
Recommended for you

Illustrator Downloadable: Tropical Shadow Overlay Kit
[memb_has_any_tag not=not tagid="282,643,655,657,1664"] Downloadables are an exc...

Illustrator Downloadable: Summer Citrus Pattern Set
Downloadables are an exclusive benefit for CreativePro members! (Not a member ye...

InDesign Downloadable: Tables SuperGuide
Downloadables are an exclusive benefit for CreativePro members! (Not a member ye...