Skip to main content

Transform Node

Convert input data from one format to another. Purpose of this node is to make simple structured transformations to the input data.

Parameters

expression

The transformation to be applied to the input data. It must be a single valid JavaScript expression without return keyword and the trailing semicolon. See examples below.

runMode

The Transform node can be run in 2 different modes:

  • Item: The node will be run for every item in the input array. Makes `item` variable available in the expression.
  • Input: The node will be run only once for the entire input. Makes `input` variable available in the expression.

Examples

Item Mode Examples

Map to boolean values based on conditions

item.price > 100;

Coalesce to a default value if null or undefined

item.price || 0;

String manipulation - Convert to uppercase

item.name.toUpperCase();

String manipulation - Concatenate text

item.firstName + " " + item.lastName;

String manipulation - Format currency

"$" + item.price.toFixed(2);

String manipulation - Extract domain from email

input.email.split("@")[1];

Change shape of the data by creating new object

{
fullName: input.firstName + " " + input.lastName,
isActive: input.lastLoginAt > new Date(Date.now() - 1000 _ 60 _ 60 _ 24 _ 30),
}

Input Mode Examples

Data Aggregation - Count items

input.length;

Sum all prices

input.reduce((sum, item) => sum + item.price, 0);

Find maximum value

Math.max(...input.map((item) => item.score));

Group by category

input.reduce((groups, item) => {
const category = item.category || "uncategorized";
if (!groups[category]) groups[category] = [];
groups[category].push(item);
return groups;
}, {});