blokboard/ Open app

Build workflows

Transform data with Code

Use JavaScript for calculations and transformations that expressions do not cover.

The Code node transforms its incoming value with JavaScript. It runs when the workflow reaches it and emits the JSON-compatible value returned by the script.

Read input and return output#

The incoming payload is available as input. Workflow values are available through variables. For example, this script selects a few fields and calculates a total:

return {
  name: input.name,
  total: Number(input.price) * Number(input.quantity),
};

The next node can read the result through {{code.output.total}}, using the actual scope shown in the expression picker.

Return ordinary data#

Return a JSON-compatible object, array, string, finite number, boolean, or null. Functions, circular references, and non-finite numbers cannot be passed as workflow results.

Use console.log() to inspect intermediate values in the node’s execution logs. Avoid logging secrets or private input.

Keep integrations in their nodes#

The Code node provides a contained JavaScript environment for data transformation. Browser globals, Node.js modules, and arbitrary host capabilities are not the interface for integration work. Use HTTP, file, and blockchain nodes for their respective operations.

Code fields are JavaScript source. Double-brace interpolation is disabled there; read input or variables directly instead of inserting an expression into the script.

Fix an error#

Inspect the node’s error and line information, check the actual input, and reduce the script to a small returned value. Build the transformation back up after that succeeds.

For simple property selection, expressions are enough. For persistent memory, use State nodes.