Built-in action Built In

Write custom JavaScript to transform data any way you need — format numbers, sort arrays, calculate values, merge objects, and more. Define a transform(input) function; the result is available as {{nodeId.result.output}}. Runs in a secure sandbox with ES6+ support. Reads and mutates workflow variables via getVar('name') / setVar('name', value) — both are scoped to variables declared on the workflow.

At a Glance

FieldValue
Action IDcode-transform
CategoryBuilt In
ConnectorNot required
Requires gasNo
Funds movementNone declared
Tagscode, transform, javascript, custom, data-processing, compute

Payload Schema

FieldTypeRequiredDescription
codestringYesWrite a 'transform(input)' function. 'input' is whatever you pass in the Input field below. Full ES6+ support, sandboxed (no network/filesystem). Read workflow variables with 'getVar('name')' (throws if the name is not declared on the workflow). Write them with 'setVar('name', value)' — value type must match the declared type, max 60 KiB per value. Writes commit atomically with node completion.
inputobjectYesThe data passed to your transform(input) function. Whatever you reference here becomes 'input' in your code. For example, if you set this to {{node.result.items}}, then 'input' is that array directly.
timeoutnumberNoExecution timeout in milliseconds (default: 5000ms, max: 10000ms)
inputTypeobjectNoDeclares the expected input type for validation (optional). Example: {"type": "array"}
outputTypeobjectNoDeclares the output type for validation and variable suggestions (optional). Example: {"type": "array", "items": {"type": "object", "properties": {"name": {"type": "string"}}}}

Result Schema

FieldTypeRequiredDescription
outputstring | number | boolean | null | array | objectYesThe result returned by your transform function. Can be any JSON-serializable value (primitive, object, array, nested structures). The output is available to subsequent workflow actions via {{nodeId.result.output}} or {{nodeId.result.output.field}} for object results.
executionTimeMsnumberYesCode execution time in milliseconds
languagestringYesLanguage used for execution

Examples

json
{ "type": "code-transform", "payload": { "code": "// When input='{{node.result.exchanges}}' (array), input IS the array:", "input": "{{prevNode.result.items}}" }, "children": []}

Payload fields can use workflow expressions such as {{$trigger.body.amount}}, {{$nodes.fetch.result.price}}, and {{$props.asset}} when the value should come from a trigger, prior node, or reusable workflow prop.