Using transform-data steps
Using transform-data steps
Transform-data steps manipulate data using JavaScript in a sandboxed environment, letting you format, filter, merge, or calculate values within Flows.
Add a transform step
- In the Flow editor, click Add Step
- Select Run Code
- Configure:
- Name: Descriptive label (e.g., “Format response”)
- Script: Write your JavaScript transformation logic
- Output Variable: Name for the result variable
- Click Save Step
Writing scripts
Write JavaScript that returns a value. All Flow variables from previous steps are available directly by their outputVariable name:
Reference output from earlier steps by their outputVariable name:
Common transformations
Array operations
Object merging
String formatting
Calculations
Available JavaScript features
Transform steps run in a sandboxed environment (Cloudflare Worker by default) and support modern JavaScript:
- Array methods (
map,filter,reduce, etc.) - Destructuring and spread operators
- Arrow functions
- Template literals
async/awaitDateobjectsMathfunctionsJSON.parseandJSON.stringify- Built-in helper utilities (available under
helpers.*)
External libraries are not available in the default sandbox. Use API call steps for external data.
The default step timeout is 5 minutes. Keep transformations focused to avoid unnecessary execution time.
Error handling
By default, if your script throws, the step does not fail the Flow. It continues with the step’s configured default value (or null if none is set) for the output variable, and records the error on the step result. Set the step’s error handling to Stop on error if a failed transformation should halt the Flow instead.
To keep going with a meaningful value rather than null, wrap risky operations in try/catch and return a structured result:
A downstream Conditional Logic step can then branch on success.
Testing transformations
You can test a single step against the variables from the most recent run, but only after the Flow has run at least once:
- Run the Flow once
- Open the step’s action menu (the ⋯ button on the step card)
- Choose Test with last run
- Review the output and iterate
Best practices
- Keep it simple: Complex logic belongs in external services
- Name clearly: Use descriptive step names that explain the transformation
- Handle nulls: Check for undefined/null values before accessing properties
- Return consistent types: Always return the same structure for predictability
Next steps
- Flow variables and templates for variable reference
- Using conditional steps for logic based on transformed data
- Using fetch-url and api-call steps for external data