# UXP and ExtendScript — InDesign

> Adobe InDesign 2027 (22.0.0.104) Object Model. How the object model in this reference is used from UXP, and where that differs from ExtendScript.

InDesign runs scripts in two engines. **ExtendScript** (`.jsx`) is the original one: JavaScript at the level of ES3, with `app` and every enumeration as globals. **UXP** (`.idjs` scripts; UXP plugins since 18.5) is modern JavaScript. Both drive the same object model — the classes, properties and methods documented here. What differs is how you reach it and a handful of rules around it.

## Reaching the object model

```js
const { app, PathType } = require("indesign");

async function main() {
  const doc = app.activeDocument;
  const page = doc.pages.item(0);        // not doc.pages[0]
  const path = page.polygons.item(0).paths.item(0);
  if (path.pathType.equals(PathType.CLOSED_PATH)) {   // not ==
    console.log("closed");
  }
  const file = await doc.fullName;      // a Promise under UXP
  console.log(file.nativePath);
}
main();
```

## Rules

| | ExtendScript | UXP |
| --- | --- | --- |
| `app`, enumerations | globals | `require("indesign")` |
| Collection item | `pages[0]` or `pages.item(0)` | `pages.item(0)` only — `[]` does not exist |
| Compare enumerations, DOM objects | `==` | `.equals()` — `==` and `===` do not work |
| Files and folders | ExtendScript `File`, `Folder` | entries from `require("uxp").storage` |
| Reading a file or folder property | the object | a Promise — `await` it |
| Passing a file | `File` | path string or UXP `File` entry |
| Passing a folder | `Folder` | path string only |
| Does a DOM object have a property? | `obj.hasOwnProperty("name")` or `"name" in obj` | `"name" in obj` only — `hasOwnProperty()` and `Object.hasOwn()` are always `false` |
| Script arguments | `app.scriptArgs.getValue("name")`; `arguments` in a script run by `doScript()` | `require("uxp").script.args` — an array of strings; `app.scriptArgs` is `undefined` |
| Script result | the value of the last expression | `script.setResult(value)` — the last expression is ignored |
| Event handler | function or `File` | function, or the path of a `.jsx` as a string — that script runs as ExtendScript |
| Output | `$.writeln()` | `console.log()` |
| User interface | ScriptUI | HTML |
| Not available | — | `$`, ScriptUI, `XML`/`XMLList` (E4X), `Socket`, `UnitValue`, `Reflection` |

`app.doScript()` still runs an ExtendScript file from UXP. Its `withArguments` reach an ExtendScript as `arguments` with their types, a UXP script as strings in `script.args` (`true` becomes `"TRUE"`). `doScript()` returns the called script's result: the last expression of an ExtendScript, the `script.setResult()` value of a UXP script.

## How this reference marks the differences

- Markdown: a type that differs carries `(UXP: …)`, for example `File` (UXP: `Promise<File>`). Methods that do not exist under UXP say _ExtendScript only — not available in UXP._ Runtime notes start with **UXP:**.
- [api.json](https://www.indesignjs.de/indesignapi/indesign/api.json): `runtimes` lists both engines. A member that differs has `uxp: { type }`, `uxp: { returns }` or `uxp: { available: false }`; notes are `notes: [{ runtime, text }]`.
- The website has an ExtendScript / UXP switch in the header that shows every page as the chosen engine sees it.
- The `.d.ts` files here describe ExtendScript. For UXP type declarations use [indesign-uxp-types](https://www.npmjs.com/package/indesign-uxp-types).

## File and folder values that are Promises under UXP

28 members. Measured at runtime in InDesign 2026 (indesign-uxp-types).

- `Application.activeScript` → `Promise<File>`
- `Application.filePath` → `Promise<Folder>`
- `Application.fullName` → `Promise<File>`
- `Assignment.documentPath` → `Promise<File>`
- `Assignment.createPackage()` returns `Promise<File>`
- `Book.filePath` → `Promise<Folder>`
- `Book.fullName` → `Promise<File>`
- `BookContent.filePath` → `Promise<Folder>`
- `BookContent.fullName` → `Promise<File>`
- `ColorSetting.cmsSettingsPath` → `Promise<File>`
- `Document.filePath` → `Promise<Folder>`
- `Document.fullName` → `Promise<File>`
- `DocumentEvent.fullName` → `Promise<File>`
- `EventListener.handler` → `Promise<File>`
- `GeneralPreference.temporaryFolder` → `Promise<Folder>`
- `HyperlinkExternalPageDestination.documentPath` → `Promise<File>`
- `ImportExportEvent.fullName` → `Promise<File>`
- `Library.filePath` → `Promise<Folder>`
- `Library.fullName` → `Promise<File>`
- `PDFExportPreset.fullName` → `Promise<File>`
- `PrintBookletPrintPreference.printFile` → `Promise<File>`
- `PrintPreference.printFile` → `Promise<File>`
- `PrinterPreset.printFile` → `Promise<File>`
- `ScriptPreference.scriptsFolder` → `Promise<Folder>`
- `ToolBox.currentToolIconFile` → `Promise<File>`
- `XMLExportPreference.preferredBrowser` → `Promise<File>`
- `XMLExportPreference.transformFilename` → `Promise<File>`
- `XMLImportPreference.transformFilename` → `Promise<File>`

## String or File: only the String under UXP

Adobe types these as `String | File`. Under UXP they return the path as a string.

- `AssignedStory.filePath`
- `Assignment.filePath`
- `GotoAnchorBehavior.filePath`
- `Link.filePath`
- `Movie.filePath`
- `OpenFileBehavior.filePath`
- `Sound.filePath`

## Objects that do not exist under UXP

In the object model, but `require("indesign")` does not export them. ExtendScript only.

- [GenAIImage](https://www.indesignjs.de/indesignapi/indesign/GenAIImage.md)
- [GenAIImages](https://www.indesignjs.de/indesignapi/indesign/GenAIImages.md)
- [GenAIModel](https://www.indesignjs.de/indesignapi/indesign/GenAIModel.md)
- [GenAIModels](https://www.indesignjs.de/indesignapi/indesign/GenAIModels.md)

## Members that do not exist under UXP

- `[]` — the index accessor on 244 collections. Use `item(index)`.
- `Application.parseJson()`
- `Application.parseJsonFile()`
- `Application.stringifyJson()`
- `Application.writeJsonFile()`
- `Document.genaiModels`
- `XMLElements.itemByName()`

## Further notes

- [GenAIImage](https://www.indesignjs.de/indesignapi/indesign/GenAIImage.md): Not available in UXP — require("indesign") does not export this object. ExtendScript only.
- [GenAIImages](https://www.indesignjs.de/indesignapi/indesign/GenAIImages.md): Not available in UXP — require("indesign") does not export this object. ExtendScript only.
- [GenAIModel](https://www.indesignjs.de/indesignapi/indesign/GenAIModel.md): Not available in UXP — require("indesign") does not export this object. ExtendScript only.
- [GenAIModels](https://www.indesignjs.de/indesignapi/indesign/GenAIModels.md): Not available in UXP — require("indesign") does not export this object. ExtendScript only.
- [ScriptArg](https://www.indesignjs.de/indesignapi/indesign/ScriptArg.md): Not reachable in UXP — app.scriptArgs is undefined there. Read arguments from require("uxp").script.args.
- [XMLElements](https://www.indesignjs.de/indesignapi/indesign/XMLElements.md): itemByName() does not work under UXP. Use evaluateXPathExpression() on the parent XMLElement instead.
- `addEventListener()` on 418 objects: The handler can also be the path of a .jsx file as a string — that script runs as ExtendScript when the event fires.
- `Application.scriptArgs`: Undefined in UXP. Read arguments from require("uxp").script.args — an array of strings; InDesign Server passes them as "name=value".
- `Application.doScript()`: A called UXP script receives withArguments as strings in require("uxp").script.args; an ExtendScript receives them as arguments with their types. doScript() returns what a UXP script passes to script.setResult() — its last expression is ignored.
- `EventListeners.add()`: The handler can also be the path of a .jsx file as a string — that script runs as ExtendScript when the event fires.

## Adobe’s documentation

- [UXP](https://developer.adobe.com/uxp/) — the platform: modules, storage, network, UI
- [InDesign UXP](https://developer.adobe.com/indesign/uxp/) — scripts and plugins in InDesign
- [Migrating from ExtendScript](https://developer.adobe.com/indesign/uxp/resources/migration-guides/extendscript/)
- [Passing arguments](https://developer.adobe.com/indesign/uxp/scripts/tutorials/arguments/) and [script result](https://developer.adobe.com/indesign/uxp/scripts/tutorials/script-result/) — `script.args`, `script.setResult()`
