When built-in nodes aren't enough, the Code node lets you write custom JavaScript (or Python) to transform data, implement complex logic, or call external libraries.
Code Node Modes
- Run Once for All Items: Process all items together (great for aggregation)
- Run Once for Each Item: Process items individually
Code Examples
Code Node — Transform Data
javascript
// Process all items at once
const items = $input.all();
const result = items.map(item => {
const data = item.json;
return {
json: {
fullName: `${data.firstName} ${data.lastName}`,
email: data.email.toLowerCase(),
isVIP: data.totalPurchases > 1000,
joinedDaysAgo: Math.floor(
(Date.now() - new Date(data.createdAt)) / 86400000
)
}
};
});
return result;