← Back to scripts
Batch Export Layers
Export all layers in a document as individual PNG files with a single click.
A simple script that exports every layer in the active document as a separate PNG file, named after the layer.
Usage
- Open your Affinity document
- Run the script from File > Scripts > Run Script
- Choose an output folder
- Each layer will be exported as
<layer-name>.png
The Script
const doc = app.activeDocument;
if (!doc) {
alert('No document open');
exit;
}
const folder = Folder.selectDialog('Choose export folder');
if (!folder) exit;
for (const layer of doc.layers) {
const filePath = new File(folder.fsName + '/' + layer.name + '.png');
const opts = { dest: filePath, type: 'png', quality: 100 };
layer.rasterize(opts);
}
alert('Exported ' + doc.layers.length + ' layers.');
Notes
- Nested layers are not recursively exported — only top-level layers.
- Adjust the
typeinoptsto export asjpg,pdf, etc. - Add error handling for production use.