See Stacksync in action with a solution architect. Book a demo ↗

Javascript Code Execution

Run custom JavaScript scripts directly inside your workflow. Use it for fast data formatting, string manipulation, date operations, or lightweight logic between nodes.

1. Add the Module

Add the JavaScript Code module to your workflow as an action node.

Workflow editor Action modules panel searched for "code", with "Javascript Code" under Code Execution pointed out by an arrow.

2. Pass Data In Context

In the module configuration panel, add context variables under the Context section. Each entry takes a Name and a Value use the variable picker to map values from upstream nodes.

Javascript Code module with a Context entry "amount" set to {{ input.body.amount }} via the variable picker and read in the script via WORKFLOW_CONTEXT.

Each context entry becomes a key on WORKFLOW_CONTEXT inside your script:

function main(WORKFLOW_CONTEXT) {
    const amount = WORKFLOW_CONTEXT.amount;
    const currency = WORKFLOW_CONTEXT.currency;
}

3. Write Your Script

Your script must define a main function. Stacksync automatically injects WORKFLOW_CONTEXT as the argument containing all your context values.

function main(WORKFLOW_CONTEXT) {
    const amount = WORKFLOW_CONTEXT.amount;
    const currency = WORKFLOW_CONTEXT.currency;
    return {
        amount: amount,
        currency: currency
    };
}

4. Return Data

Whatever main returns becomes the node's output, available to downstream nodes via standard node referencing.

Workflow Execution Logs for a successful run, with the Javascript Code Execution output returning amount 100 and currency "USD" highlighted.

Reference in downstream nodes:

{{ your_module_id.amount }}
{{ your_module_id.currency }}

Debugging: console.log() output is captured and surfaced under metadata.stdout in the execution logs. Use it for debugging, it does not pass data downstream.

Available Libraries

LibraryUse case
dayjsDate parsing and formatting
momentDate manipulation
live-plugin-managerDynamic module loading
Node.js 23 standard libraryAll built-in modules

Note: You cannot install additional packages at runtime with npm install.

Limits

LimitValue
Timeout6s
Memory8 GB
FilesystemRead-only, no writes
Runtime packagesPre-installed only

Watch out: Avoid using JavaScript for slow HTTP calls, heavy loops, or large dataset operations as the timeout is 6 seconds, use the Python Code module instead.

On this page