Small experiments in Adobe Illustrator scripting (ExtendScript, .jsx): documents, layers, paths, CMYK color, and generative layouts. This repo keeps an original scratch script as a snapshot and adds clean, runnable examples you can open and learn from.
Illustrator can be driven with JavaScript for ExtendScript (legacy engine, still widely used). Scripts talk to the app object: create documents, add pathItems, set fills, loop with randomness, and so on. The same language ideas as browser JS apply (for loops, functions, Math.random), but the DOM is Illustrator’s object model, not HTML.
For the newer UXP plugin model the APIs differ; everything under scripts/ here targets File → Scripts style ExtendScript.
- Open Adobe Illustrator.
- File → Scripts → Other Script… (macOS/Windows).
- Choose an
.jsxfile from this repo, for examplescripts/examples/03-random-cmyk-rectangles.jsx. - Illustrator executes the script; many samples call
app.documents.add(), so you get a new document each run.
Optional:
- Put scripts (or aliases) in Illustrator’s Scripts folder so they appear under File → Scripts without browsing. Typical locations are documented in Adobe’s scripting guide (user Presets folder per OS/version).
- Use ExtendScript Toolkit (deprecated but still referenced) or VS Code with a JSX/ExtendScript workflow if you want breakpoints and
$.writelnoutput in a JavaScript console for debugging.
| Path | Purpose |
|---|---|
scripts/script_illustrator.jsx |
Archive — original experiments: commented blocks, nested layers, random rectangles, and commented path/staff snippets. Left intentionally as-is. |
scripts/examples/*.jsx |
Teaching scripts — same ideas split into small, commented files (01–05). |
png/ |
Raster exports / screenshots for the gallery below. |
svg/ |
Vector exports where relevant. |
ai/ |
Native Illustrator artwork linked to some experiments. |
| File | What it demonstrates |
|---|---|
01-document-and-layers.jsx |
app.documents.add(), layers.add(), nested layer names. |
02-paths-stroke-and-fill.jsx |
pathItems.add() + setEntirePath, pathItems.rectangle, CMYKColor, stroke width, opacity. |
03-random-cmyk-rectangles.jsx |
Loops, Math.random, many overlapping shapes (similar to the active part of the archive script). |
04-nested-loop-lines.jsx |
Nested for loops driving line endpoints. |
05-music-staff.jsx |
A reusable staff() function and repeated calls. |
Coordinates: pathItems.rectangle(top, left, width, height) and setEntirePath([[x, y], …]) use Illustrator’s document coordinate system (points). If art looks off-screen, adjust the numeric ranges to match your artboard or ruler origin.
Performance: Scripts that create thousands of objects (e.g. example 03) can be slow; reduce count while iterating.
Outputs vary with randomness and document settings; these images are from earlier runs and related artwork in this repo.
Additional assets in png/ (script44-01.png, Untitled-1-01.png, test.png, …) are extra exports you can browse locally.
- Adobe Illustrator scripting — official entry point and PDF scripting guides.
- Object model reference: look for Illustrator JavaScript Scripting Reference in Adobe’s developer materials for the exact properties on
PathItem,Layer,Document, etc.
MIT — Copyright (c) 2026 Jeff Mentch.



