Docs
Sign in

JavaScript

The JavaScript node runs a JavaScript script as a step in a workflow, with variables you map in as JSON.

Screenshot to add: A JavaScript node with its settings panel showing the JavaScript code, Input mapping and Output key fields.

The palette describes it as "Run JavaScript". The node card tags it "Node.js".

When to use it

Use it when you need a custom calculation or data change written in JavaScript. If you want to choose the language on the node, or use TypeScript, use the Code node.

Settings

FieldWhat it doesNotes
JavaScript codeYour scriptHint "Write your script below"
Input mapping (JSON)The variables made available to the scriptHint "Variables available in script". Default {}
Output keyThe name the result is stored underDefault script_output in the form. A new node starts with js_output

A new node starts with this code:

async function run(input) {
  // Your logic here
  return { result: input };
}

Inputs and outputs

HandleWherePurpose
InputTopThe step that comes before
OutputBottomContinues the workflow with the script's result

Example

This is an illustrative example. You want to tidy up a customer name.

  1. In Input mapping (JSON), map the name from the previous step into a variable.
  2. In JavaScript code, trim and format the name and return it.
  3. Read the cleaned name in the next step using the Output key.

Tips

  • Keep the function name run, as in the starter code.
  • Make sure Input mapping (JSON) is valid JSON.
  • Use the Code node if you need to install npm packages from the settings panel.