How to Automate Adobe InDesign with ExtendScript (Complete Guide)

Production-grade ExtendScript patterns for batch export, data merge, and the dataset-driven design pattern that saves hours per week.

If you produce more than 10 InDesign files a week from a template, ExtendScript pays for itself in a week. Here are the patterns we use across hundreds of client projects.

What ExtendScript can do

Anything you can do via the UI, scripted. Batch export to PDF/IDML, data merge (JSON/CSV → template), find-replace at scale, asset linking, preflight validation.

Hello world: batch export every open doc to PDF

var docs = app.documents;
var preset = app.pdfExportPresets.itemByName("[High Quality Print]");
for (var i = 0; i < docs.length; i++) {
  var d = docs[i];
  var out = File(d.filePath + "/" + d.name.replace(".indd", ".pdf"));
  d.exportFile(ExportFormat.PDF_TYPE, out, false, preset);
}

Save as .jsx, double-click in InDesign → ExtendScript Toolkit, or place in your Scripts folder.

Data-driven design pattern

For batch generation (1000 product catalog pages from a JSON), the pattern is:

  1. Build a template with placeholders ([NAME], [PRICE], etc.)
  2. Loop over data
  3. For each record, duplicate template, replace placeholders, export
var data = JSON.parse(File("data.json").read());
var template = app.open(File("template.indd"));
for (var i = 0; i < data.length; i++) {
  var copy = template.duplicate();
  replacePlaceholders(copy, data[i]);
  copy.exportFile(ExportFormat.PDF_TYPE, File("out/" + i + ".pdf"), false);
  copy.close(SaveOptions.NO);
}

When to use UXP instead

ExtendScript is legacy — works in all CC versions but Adobe is migrating to UXP plugins (modern JS, async/await, manifests). For:

Common patterns we ship

Hire an Adobe scripts developer →

Need this built for you?

Hire a vetted Nexora expert. Escrow-protected. Fixed price. From $65.

Browse automation services →