Batch Export Illustrator Artboards to SVG with ExtendScript
Automate repetitive SVG exports from Illustrator artboards using ExtendScript, with version caveats and verification steps.
06 Jul 2026, 15:17 UTC

You open an Illustrator file with twenty artboards and need each one as a standalone SVG for a design system. Exporting them one at a time through File > Export > Export As is slow, and it is easy to forget a suffix, misalign an artboard, or export the wrong bounding box. Adobe Illustrator exposes its document object model through ExtendScript, an ECMAScript 3-based JavaScript implementation, so you can script the loop instead of clicking through the dialog repeatedly.
ExtendScript can batch-export artboards to SVG, but you must write ES3-compatible code, sanitize filenames, and verify output because defaults and prompts vary by Illustrator version.
What ExtendScript can and cannot do here
ExtendScript is Illustrator's legacy scripting engine. It gives scripts access to app.activeDocument, the artboards collection, and export option objects such as ExportOptionsSVG. Scripts usually use the .jsx extension and run from File > Scripts > Other Script.
The engine follows ECMAScript 3, so it lacks const, let, arrow functions, promises, and modules. Use var and traditional function declarations. Adobe's newer UXP plugin model exists, but Illustrator's UXP support is more limited than Photoshop's, making ExtendScript the more practical choice for this automation today.
Worked example: export every artboard to SVG
This script iterates the active document's artboards, sanitizes each artboard name for the filesystem, enables artboard clipping, and writes one SVG per artboard.
// Run from Illustrator: File > Scripts > Other Script
// ES3-compatible: use var, no arrow functions or const/let
var exportFolder = new Folder("/path/to/export/folder");
var doc = app.activeDocument;
if (doc === null || doc.artboards.length === 0) {
alert("Open an Illustrator document with at least one artboard.");
} else {
var options = new ExportOptionsSVG();
options.artboardClipping = true;
for (var i = 0; i < doc.artboards.length; i++) {
var artboard = doc.artboards[i];
var safeName = artboard.name.replace(/[^a-zA-Z0-9_-]/g, "_");
var targetFile = new File(exportFolder.fsName + "/" + safeName + ".svg");
doc.artboards.setActiveArtboardIndex(i);
doc.exportFile(targetFile, ExportType.SVG, options);
}
alert("Export complete. Check " + exportFolder.fsName);
}
Where to run: inside Illustrator, choose File > Scripts > Other Script and select the .jsx file. Required permissions: the user account running Illustrator needs write access to exportFolder. The exact ExportType constant and property names can differ by Illustrator release, so confirm them against your installed version's ExtendScript DOM reference before running.
Expected check: after the script finishes, open the export folder and confirm one .svg file per artboard. Open one file in a text editor or browser and look for a viewBox attribute matching the artboard dimensions.
Risks: artboard names containing slashes, colons, or other invalid filesystem characters can break the path; the replacement above mitigates that. Existing files with the same name may be overwritten without warning. Missing fonts or locked preferences can still trigger interactive dialogs even when a script runs.
Limitations and rollback
ExtendScript debugging is more limited than modern browser or Node.js development, and there are no promises or async patterns to rely on. The scripting DOM is comparatively stable across Creative Cloud releases, but default export behavior and UI prompts can change between major versions. Test on the oldest Illustrator release your pipeline targets.
Because this operation writes files to disk, rollback means manually deleting the exported .svg files from exportFolder. Illustrator's Edit > Undo does not reverse filesystem writes, and the script does not modify the source document.
Verification and next steps
Check the Illustrator version under Help > About. Run the script on a copy of your document, not the only master file. Inspect exported SVGs for expected artboard bounds, embedded fonts, and CSS output to confirm that ExportOptionsSVG settings were applied as intended.
Start with a single document and two or three artboards. Confirm the files appear and the viewBox values look right, then add the script to your batch pipeline. Treat the first run as an experiment, not a production export.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.