Skip to main content

Overview

The Code Node lets you write custom JavaScript code that runs during your workflow. Use it when you need logic that goes beyond what other nodes offer: custom transformations, calculations, string manipulation, or any data processing that requires full programmatic control.

Required Configuration

  • JavaScript Code: The code to execute. Must include a return statement that defines the node’s output.

Optional Configuration

  • Label: Display name for the node (defaults to “Code”)
  • Requires Auth: Whether this node needs user authentication (default: false)

Accessing Data

Inside your code, use the $() function to reference data from other nodes:
  • $("Node Label"): Access any previous node’s output by its label
  • $("startNode"): Access the original input from the frontend
  • __user_id__: The authenticated user’s ID (available when Requires Auth is enabled)
Your code must include a return statement. The returned value becomes the node’s output.
// Example: transform data from a previous node
const data = $("Query Users");
const result = data.map(item => ({
  ...item,
  fullName: item.firstName + " " + item.lastName,
  processed: true
}));

return result;

Connections

Code nodes fit anywhere in your workflow: Input from: Any node type that produces data Output to: Any node type that consumes data:
  • Mutation nodes (save processed results)
  • Query nodes (use computed values as parameters)
  • HTTP Request nodes (build custom request payloads)
  • Agent nodes (prepare structured input for AI)
  • If-Else nodes (route based on computed values)
  • Edit Fields nodes (further reshape output)
  • Return nodes (end workflow with computed output)
  • Other Code nodes (chain complex logic across steps)

Common Use Cases

Custom Data Transformation. Reshape, merge, or filter data in ways that Edit Fields cannot express. Calculations and Aggregation. Sum totals, compute averages, or derive new values from input data. String Processing. Parse, format, or validate strings with full regex and string method support. Conditional Logic. Apply complex branching or business rules that go beyond simple if-else checks.

Example Workflows

  • Data Pipeline: Query Node → Code (aggregate results) → Mutation (save summary)
  • API Integration: HTTP Request → Code (parse and validate response) → Edit Fields (format output)
  • User Processing: Form Input → Code (validate and transform) → If-Else (route by result)

Edit Fields Node

Transform data with a visual field mapper

If-Else Node

Route workflows based on conditions

For Loop Node

Iterate over arrays of data

Return Node

End workflows with computed output