For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Dashboard
User GuideDeveloper GuidesAPI Reference
User GuideDeveloper GuidesAPI Reference
  • Getting Started
    • What is Runtype?
    • Creating your account
    • Platform Keys vs. BYOK
    • Understanding the Runtype UI
    • Quickstart: Social Media Post Generator
    • Quickstart: From Agent to Chat Widget
  • Dashboard
    • What is the Dashboard?
    • Daily Executions
  • Playground
    • What is the Playground?
  • Products & Surfaces
    • What are Products?
    • What are Surfaces?
    • Creating a Product
    • Setting up a Chat Surface
    • Setting up an API Surface
    • Setting up an MCP Surface
    • Setting up an A2A Surface
    • Setting up a Slack Surface
    • MCP authentication
    • Authenticating with product API keys
    • Embedding the chat widget (script tag)
    • Embedding the chat widget (React)
    • Surface orchestration modes
    • Product views
    • Adding Capabilities to a product
    • Connecting external agents
    • How A2A works
    • Connecting to Cursor / VS Code
    • Connecting to Claude Desktop
    • Scoping API keys to capabilities
    • Auto-generated OpenAPI spec
    • Calling your API endpoints
    • Client tokens and domain restrictions
    • AI-powered theme generation
    • Widget theming and customization
    • Product versioning and status
  • Flows
    • What are Flows?
    • Creating and Editing Flows
    • Flow step types overview
    • Agent and Flow Templates
    • Using prompt steps
    • Using transform-data steps
    • Using conditional steps
    • Using fetch-url and api-call steps
    • Using record steps (upsert/retrieve)
    • Flow variables and templates
    • Flow versioning and publishing
    • Running flows in batch
    • Handling batch failures
    • Debugging flows
  • Agents
    • What are Agents?
    • Creating and configuring Agents
    • Agent tools
  • Records
    • What are Records?
    • Creating and managing records
    • Using records in flows
    • Filtering and searching records
  • Tools
    • What are Tools?
    • Built-in Tools
    • Creating custom tools
    • Creating external tools
    • Runtime tools
  • Evals
    • What are Evals?
    • Running an Eval
    • Interpreting eval results
  • Schedules
    • What are Schedules?
    • Automating batch processing
  • Logs
    • What are Logs?
    • Working with Logs
  • Integrations
    • Connecting AI model providers
    • Slack integration
    • Google Workspace integration
    • GitHub integration
    • Linear integration
    • Weaviate (vector search)
    • Firecrawl (web scraping)
    • Exa (web search)
  • Settings
    • What's in Settings?
    • Available AI models
    • What are Organizations?
    • Managing AI models
    • Managing API keys
    • Billing and plans
    • Usage data
    • Team members and permissions
    • Appearance and preferences
    • Integrations (PostHog, Weaviate, Daytona)
  • Troubleshooting & FAQ
    • FAQ
    • Rate Limits and Usage
    • Managing Runtype with Claude
    • Flow execution failures
    • Common errors and solutions
    • Authentication issues
Dashboard
LogoLogo
On this page
  • Add a transform step
  • Writing scripts
  • Common transformations
  • Array operations
  • Object merging
  • String formatting
  • Calculations
  • Available JavaScript features
  • Error handling
  • Testing transformations
  • Best practices
  • Next steps
Flows

Using transform-data steps

Was this page helpful?
Previous

Using conditional steps

Next
Built with

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

  1. In the Flow editor, click Add Step
  2. Select Transform Data
  3. Configure:
    • Name: Descriptive label (e.g., “Format response”)
    • Script: Write your JavaScript transformation logic
    • Output Variable: Name for the result variable
  4. Click Save Step

Writing scripts

Write JavaScript that returns a value. All Flow variables from previous steps are available directly by their outputVariable name:

1// Access a variable called "customer_data" from a prior step
2const formatted = {
3 name: customer_data.name.toUpperCase(),
4 email: customer_data.email.toLowerCase(),
5 timestamp: new Date().toISOString()
6};
7
8return formatted;

Reference output from earlier steps by their outputVariable name:

1const summary = generate_summary; // outputVariable from a prior prompt step
2const wordCount = summary.split(' ').length;
3
4return {
5 summary: summary,
6 wordCount: wordCount,
7 readingTime: Math.ceil(wordCount / 200) + ' minutes'
8};

Common transformations

Array operations

1// Filter and map array — "order_data" is an outputVariable from a prior step
2const highValueOrders = order_data.orders
3 .filter(order => order.amount > 1000)
4 .map(order => ({
5 id: order.id,
6 total: order.amount,
7 formattedTotal: '$' + order.amount.toFixed(2)
8 }));
9
10return highValueOrders;

Object merging

1// Combine data from multiple sources — reference outputVariable names directly
2return {
3 ...customer_data,
4 ...order_history,
5 enrichedAt: new Date().toISOString()
6};

String formatting

1// "contact_info" is an outputVariable from a prior step
2const name = contact_info.firstName + ' ' + contact_info.lastName;
3const slug = name.toLowerCase().replace(/\s+/g, '-');
4
5return { name, slug };

Calculations

1// "cart" is an outputVariable from a prior step
2const items = cart.items;
3const subtotal = items.reduce((sum, item) => sum + item.price, 0);
4const tax = subtotal * 0.08;
5const total = subtotal + tax;
6
7return { subtotal, tax, total };

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/await
  • Date objects
  • Math functions
  • JSON.parse and JSON.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

Wrap risky operations in try/catch:

1try {
2 const parsed = JSON.parse(raw_data);
3 return { success: true, data: parsed };
4} catch (error) {
5 return { success: false, error: error.message };
6}

Testing transformations

Use the step tester to validate logic:

  1. Click Test on the transform step
  2. Provide sample input
  3. Review output
  4. Iterate until correct

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