Loopfour
Blocks

Transform Block

Map and reshape data between systems using declarative field mapping

The Transform block maps data from one shape to another using declarative field mapping. Use it to convert between system formats -- for example, mapping a Stripe invoice to a QuickBooks invoice structure.

Configuration

Mapping

Define field mappings as key-value pairs where keys are output field names and values are template expressions referencing input data.

{
  "customerEmail": "{{input.data.object.customer_email}}",
  "amount": "{{input.data.object.amount_paid}}",
  "invoiceNumber": "{{input.data.object.number}}",
  "paidAt": "{{input.data.object.status_transitions.paid_at}}"
}

Computed Fields

Mappings support expressions for simple transformations:

{
  "amountDollars": "{{input.data.object.amount_paid / 100}}",
  "displayName": "{{input.data.object.customer_name || 'Unknown'}}",
  "isPaid": "{{input.data.object.status === 'paid'}}"
}

Outputs

OutputTypeDescription
resultJSONThe transformed data object with all mapped fields

When to Use Transform vs Code

ScenarioUse
Simple field renamingTransform
Nested object restructuringTransform
Basic calculationsTransform
Loops, conditionals, aggregationsCode block
External API callsIntegration block or Code block

Best Practices

  • Name output fields descriptively. Use camelCase and match the target system's naming convention.
  • Handle missing fields. Use the || operator to provide fallback values: {{input.field || 'default'}}.
  • Keep transforms focused. One Transform block per system-to-system mapping. Do not try to handle all transformations in a single block.

Frequently Asked Questions

The Transform block supports template expressions with dot notation for field access, basic arithmetic (+, -, *, /), comparison operators (===, !==, >, <), logical operators (&&, ||), and the ternary operator for inline conditionals.

Yes. Use dot notation to access deeply nested properties: {{input.data.object.customer.address.city}}. Array indexing is also supported: {{input.data.items[0].amount}}.

If a referenced field is undefined, the output field is set to null. Use the || operator to provide fallback values and avoid null outputs.

The Transform block outputs a flat JSON object by default. For array transformations, use the Code block which has full JavaScript array methods available.

On this page